This guide is one section of a larger guide to installing a cent 6.x server in virtual box for development purposes with different applications. The top level guide with links to all of the sections is here: https://gist.github.com/ryanguill/5149058 Some instructions in this guide may assume a configuration from other parts of the guide.
#Useful Linux Commands
linux basic administration guide: http://library.linode.com/using-linux/administration-basics
More commands: http://www.pixelbeat.org/cmdline.html
Bash command tweaks: http://brakertech.com/one-liners/bashrbashrc-tweaks-for-rhel-or-centos/
shutdown the computer and halt:
# shutdown -h 0
show the tail 100 lines of the cf exception log, auto refreshing (-f)
# tail -f --lines 100 /opt/coldfusion9/logs/exception.log
restart apache
# sudo /etc/init.d/httpd restart
copy dir from "port 80" to a port recursively (--recursive), preserving ownership and rights (-p) and verbose mode (-v)
# sudo cp --recursive -p /var/www/html/dir /var/www/html/8009 -v
remove a folder recursively and force it to delete ignoring read-only errors
# sudo rm -R -f /var/www/html/8007/dir
change ownership to apache of a directory recursvly
# sudo chown -r apache /var/www/html/8003/dir
update the file location database for the locate command
# sudo updatedb
locate a file (If it is desired to perform a more sophisticated search, including searching by attributes other than name (e.g., by size, creation date or location), the find command should be used.)
# locate file
locate any pdf files
# locate "*.pdf"
locate any pdf files and pipe the output to the more program
# locate "*.pdf" | more
see what is currently running / memory usage / cpu usage
# top
or
# ps -aux
see current disk usage
# df -h
see the total disk usage of a folder
# du -sh /path/to/folder/or/file
or disk usage of the current folder
# du -sh *
grep search add -i to make it case insensitive - you need sudo to keep from getting permission denied errors
# grep -i -r -n 'search string' /var/www/html/
# sudo grep -r -i -n 'search string' /var/www/html/ | more
tar a directory
# sudo tar -cf filename.tar directory/
untar a file
# tar -xvf filename.tar
find all files in /var/www/html larger than 50M and print them and their size to the console: (centOS - ubuntu may be different variables in awk)
# sudo find /var/www/html -type f -size +50000k -exec ls -lh {} \; | awk '{ print $9 ": " $5 }'
create a symbolic link for the second path that points to the first
# ln -s /var/www/html/cfide /var/www/html/8008/CFIDE
search for ip addresses in code
# sudo egrep -i -n -r '\b(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\b' /var/www/html/ > /var/www/html/ipaddresses-grepresults.txt
create an empty file called foo.txt
# touch foo.txt
append a string to a file called foo.txt (will create the file if it doesnt exist)
# echo 'string to append' >> foo.txt
check if a package is installed
# rpm -qa | grep package-name