Few useful Linux commands
Published on 02 November 12
2644
1
Here are few useful unix/linux commands, which any developer needs to know. Hoping all programmers find it handy :-)
#Zipping a folder
$ tar czvf folder_name.tar.gz folder_name
#Finding string in all files of folder
$ find . | xargs grep 'your string'
#Removing files if rm -fR does not work
$ find . -name '*filename_pattern*' | xargs rm
#Killing Linux process by name
$ kill `ps -ef | grep process_name_pattern | grep -v grep | awk '{print $2}'`
#Linux command for find and replace
$ sed 's#FIND_STRING#REPLACE_STRING#g' File_Name > New_File_Name
#Datetime update cron
#Type crontab –e as su (super user) and paste following, replace
#your_datetime_server with IP or name of your server.
5 0 * * * /usr/sbin/ntpdate your_datetime_server > /dev/null 2>&1
#Disk space usage in a folder
#Change directory to your server and type
$ du -ks -h *
#Find and remove files 14 days old
$ find /folder_name/ *file_name_pattern* -atime +14 -print | xargs rm
#Zipping a folder
$ tar czvf folder_name.tar.gz folder_name
#Finding string in all files of folder
$ find . | xargs grep 'your string'
#Removing files if rm -fR does not work
$ find . -name '*filename_pattern*' | xargs rm
#Killing Linux process by name
$ kill `ps -ef | grep process_name_pattern | grep -v grep | awk '{print $2}'`
#Linux command for find and replace
$ sed 's#FIND_STRING#REPLACE_STRING#g' File_Name > New_File_Name
#Datetime update cron
#Type crontab –e as su (super user) and paste following, replace
#your_datetime_server with IP or name of your server.
5 0 * * * /usr/sbin/ntpdate your_datetime_server > /dev/null 2>&1
#Disk space usage in a folder
#Change directory to your server and type
$ du -ks -h *
#Find and remove files 14 days old
$ find /folder_name/ *file_name_pattern* -atime +14 -print | xargs rm
This review is listed under
Open Source
and Operating Systems
Community
Related Posts:
Thank you, this helped alot.