A list of unix commands for basic unix command reference. Most of these unix commands will work on the linux command line. However, very few of these commands will work on Windows unless you have the proper tools install.
command –help - Explains how to use the command and also gives many command line options.
command -h - An alternative syntax for finding information on a given command.
man command - Displays a manual for a given program to the screen.
General system commands
uname -a - Displays information like the operating system, hostname, and linux kernel.
date - The date command shows the current time and date.
date -u - Displays the time in Greenwich Mean Time (GMT), universal time.
uptime - The uptime command displays how long the system has been running since the last reboot and also the load averages.
whoami - The whoami command displays the user you are logged is as.
who - The who command displays who is logged into the server.
w - The w command is similar to the who command, but it includes more details.
df - The df command displays disk usage information on all mounted file systems.
su - The su command switches the user to the “super user” or root.
su user - The current user will be switched to user.
exit - The exit command will terminate the current unix of telnet session.
What processes are running?
ps - The ps command displays processes that you are currently running.
ps -aux - Displays all running processes on the system.
top - The top command provides processor activity in real time.
kill process - Kills a process specified by the process id (PID).
killall -9 process - Kills a process running a command specified by name.
File system commands
ls - The ls command list files in a directory.
ls -al - List all files in a directory with other details.
cd - The cd command changes the current directory to the users home directory.
cd directory - Changes the current directory to directory.
pwd - The pwd command displays the users current directory.
mkdir name - The mkdir command creates a directory called. name.
rm file - Delete file from your system.
rm -r directory - Delete directory from your system.
mv source destination - The mv command moves source, file or directory, to destination.
cp source destination - The cp command copies source, file or directory, to destination.
cp -R source destination - Copies recursively source to destination.
Creating, editing, and viewing text files
vi file - Opens the VI text editor to edit or create file. VI is an advanced unix text editor. Visit [Mastering the VI]:http://www.eng.hawaii.edu/Tutor/vi.html editor for help on using the VI text editor.
pico file - Opens the PICO text editor to edit or create file.
nano file - Opens the NANO text editor to edit or create file. Very similar to PICO.
cat file - The cat command displays the full contents of file on the screen.
head file - The head command displays the first ten lines of file.
tail file - The tail command displays the last ten lines of file.
Compressing and tarring
gzip file - Compresses file using gzip compression.
gzip -d file - Decompress file, a file that has been compressed using gzip.
tar -czf archive.tar.gz source - Creates a tar archive of source and gzip compresses it.
tar -zxf archive.tar.gz - Extracts a tar archive that has been compressed using gzip.
locate name - Searches the system using an index and displays the matches.
updatedb - The updatedb command updates the indexed database for locate.
whereis name - Searches for a program called name.
find name - Searches the system without using an index, making this search slower.
wget http://www.example.com/file.tar.gz - Downloads a file from an external host.
dig domain - Displays information about a domain name.
whois domain - Displays the whois record for domain.
Piping is passing data from one program to another essentially. I will explain piping some more and give example in the future.
mysqldump –opt database | gzip > destination - Creates and optimized database backup of database then passes the output directly to gzip to compress the data.
mysqldump –opt -A | gzip > destination - Does the same thing as above, but for all of the databases on the server.
mysql < file - Imports an SQL file file into MySQL.
php file - Executes the PHP code in file and displays output.
php -f file - Does the same thing as the previous command.
php -r “code“ - Runs PHP code without script tags and displays the output.