I started this thread to keep track of some of the linux shell commands that i use on a daily basis hoping that it'll be of help to someone and for myself as a reminder since i keep forgetting some of the not so popular ones.
If you know of a useful command that is not listed here please feel free to post it to be added to the list, this list will be constantly updated...
==============================================
- Lists hidden files and folders in the current directory with details:
ls -al
ll (that's a double L in lower case)
- Change your account's password
passwd
- Create a new directory
mkdir
- Creates symolic a link for a file or directory
ln
ex:
ln –s /usr/local/apache/conf/httpd.conf /etc/httpd.conf
- Check server disk space in human readable format
df -h
- Check current running processes and server load
top
ex: top -d 1 -c (refresh every 1 sec and display running command)
- Display current logged in user with thier IP address
w
- Output a complete list of current running processes
ps -auxww
- Check for running net services and listening port
netstat -A inet -lnp
- Differnet ways to stop/start/restart apache:
apachectl stop
apachectl startssl
apachectl restart
service httpd restart
/etc/init/httpd restart
- Backup a database
mysqldump -uUsername -p dbname > anyname.sql
- Restore a database
mysql -u username databsase -p < databasefile.sql
- Rebuild your rpm database in case of rpm errors
cd /var/lib/rpm/
rm __db*
rpm --rebuilddb
- A workaround to delete a huge number of files that end with .wrk as an example (rm command is limited to a number of files to delete due to kernel restrictions)
find . -name '*.wrk' | xargs rm
- Watch log files in realtime
tail -f /path/to/logfile
ex: tail -f /var/log/exim_maillog to watch Exim log file
- Show MySQL process list
mysql -e 'show processlist'
mysqladmin pr
-List users IP connected to apache
netstat -lanp | awk '{print $5}' | cut -d ':' -f1 | sort | uniq -c
- Update installed and install missing Perl modules on cPanel servers
/usr/local/cpanel/bin/checkperlmodules
- List opened files used by a process # 1234
lsof -p 1234
- This command print out bootup messages, useful for analyzing hardware problems
dmseg
dmseg > boot_message.txt (send output to a text file)
- List disk usage of all files and folders under /tmp
du -h -s /tmp/*
- Copy a file like php.ini to multiple directories
find * -type d|xargs -i cp --verbose php.ini {}/.
- Replace a string like :blackhole: with :fail: in all files under /etc/valiases directory
replace :blackhole :fail: -- /etc/valiases/*
More to come soon...