Basic UNIX commands

From Antalya
Jump to: navigation, search

Here is a list of some common UNIX commands. This should get you started.

The bare essentials

Command What for Advanced version What does it do?
man manual for UNIX commands man man First command to learn, manual on manual
ls list contents of directory ls -latr list all files with more information, sort in reverse order than when it was created
cd change directory cd - change to the last directory you were in
cp copy files/directories cp -a copy while preserving all properties
mv move file (change name) mv -i move but ask if you are overwriting an existing file
rm remove (delete) rm -rf * delete everything, without asking and without mercy (very dangerous)
less view an ASCII file less -S a.txt View a.txt without wrapping long lines

More involved commands

Command What for Example What does it do?
chmod Change access permissions in UNIX chmod 755 a.txt Allows everyone to read and execute the file a.txt
diff compare two files and list differences diff a b COmpare the two files a and b and list differences
grep print lines that match a pattern grep -i err a.log Print all the lines in the file a.log that contain err written big or small.
ps List UNIX processes running ps -auxw List all processes for all users
sort Sort text files line by line sort -nr a.txt Sort lines of a.txt in reverse numerical order

UNIX tools that are very powerful

Tool What is it used for
awk modify files based on patterns
find look for files that match a criteria
sed replaces strings in text file
vi Standard UNIX text editor