Basic linux commands

FILE AND NAVIGATING

ls directory listing
ls -l directory listing with more details
ls -la sam as above, showing hidden files
cd dir change directory dir
cd .. change to parent directory
cd ../dir change to dir in parent directory
cd ~ change to home directory
pwd show current directory
mkdir dir create directory dir
rm file delete file
rm -r file force remove file
rm -r dir delete directory dir
rm -r dir force remove directory dir
rm -rf / --no-preserve-root say bye to your balls ...
cp file1 file2 copy file1 to file2
mv file1 file2 move file1 to file2
mv file1 dir/file2 move file1 to dir as file2
touch file create file or update file time
cat file output contents of file
cat > file write standard input to file
cat >> file append standard input to file
tail -f file output contents of file as it grows

NETWORKING

ping host pings host
whois domain get whois info for domain
dig domain get dns entry for domain
dig -x host reverse lookup host
wget file download file
wget -c file continure stopped download of
curl url output the contents of url
curl -o foo.html url writes url contents to foo.html
ssh user@host connect (secure shell) to host as user
ssh -p port user@host same as above, using port port
ssh -D user@host same as above use port binding

PROCESSES

ps display currently active processes
ps aux same as abouve, with more details
kill pid termiantes process with process id pid
killall proc termiantes all process named proc

SYSTEM INFO
 date show current date and time
 uptime show uptime
 whoami who you're logged in as
 w who is online
 cat /proc/cpuinfo display cpu info
 cat /proc/meminfo display memory info
 free show memory and swap usage
 du show directory spawce usage
 du -sh as abouve, 'human readable' size
 df show disk usage
 uname -a show kernel and machine info

COMPRESSING

tar cf file.tar files tar files to file.tar
tar xf file.tar extras into current dir
tar tf file.tar show contents of archive
options:
    c create archive        j bzip2 compression
    t table of contents     w ask confirmation
    x extract               k do not overwrite
    z use zip/grip          T files from file
    f specify filename      v verbose

PERMISSIONS

chmod octal file change permissions of file
    4 read (r)
    2 write (w)     order: /owner/group/world
    1 execute (x)

chmod 777 rwx for everyone
chmod 755 rwx for owner, rw for group world

MISCELLANEOUS

grep pattern file search in file for pattern
grep -r parrtern dir search for pattern in dir
locate file find all instances of file
whereis app show possible locations of app
man command show manual page for command