File Commands:
ls – Directory listing
ls -al – formatted listing with hidden fies
cd dir – Change directory to dir
cd -change to home
pwd – show current diectory
mkdir dir – create directory file
rm – r dir – delete directory dir
rm -f file – forceremove file
rm -rf dir – remove directory file
cp file1 file 2 – copy file1 to file2
mv file1 file2 – move file1 to file2
ln -s file link – create symbolic link “link” to file
touch file – create or update file
cat > file – plcase standard input into file
more file – output the contents of the file
less file – output the contents of the file
head file – output first 10 lines of file
tail file – output last 10 lines of file
tail -f file – output contents of file as it grows
SSH:
ssh user@host – connect to host as user
ssh -p port user@host – connect using port p
ssh -D port user@host – connect and use bind port
Installation:
./configure
make
make install
NETWORK:
ping host – ping host ‘host’
whois domain – get whois for domain
dig domain – get DNS for domain
dig -x host – reverse lookup host
wget file – download file
wget -c file – continue stopped download
wget -r url – recursively download files from url
SYSTEM INFO:
date – show current date/time
cal – show this month’s calendar
upptime – show uptime
-w – display who is online
whoami – who are you logged in as
unmae -a – show kernel config
cat /proc/cpuinfo – cpu info
cat /proc/meminfo – memory information
df – show disk usage
du – show directory space usage
du -sh – human readable size in GB
free – show memory and swap usage
whereis app – show which app will be running by default
SEARCHING:
grep pattern files – search for pattern in files
grep -r pattern dir – search recursively for pattern in dir
command | grep pattern – search for pattern in the output command
locate file – find all instances of file
PROCESS MANAGEMENT:
ps – display currently active processes
ps aux – ps with lot of detail
kill pid – kill process pid ‘pid’
killall proc – kill all processes named proc
bg – lists stopped/background jobs, resume stopped job in the bacground
fg n – brings job n to foreground
FILE PERMISSIONS:
chmod octal file – change permission of file
4 – read (r)
2 – write (w)
1 – execute (x)
order : owner/group/world
eg:
chmod 777 – rwx for everyone
chmod 755 – rw for owner, rx for group/world
COMPRESSION:
tar flags:
c- create archive j – bzip2 compression
t – table of contents k – do not overwrite
x – extract T – files from file
f – specific filename w- ask for confirmation
z- use zip/gzip v- verbose
gzip file – compress file and rename to file.gz
SHORTCUTS:
ctrl+c – halts current command
ctrl+z – stops current command
fg – resume stopped command in foreground
bg – resume stopped command in backgound
ctrl+d – log out of current session
ctrl+w – erases one word in current line
ctrl+u – erases whole line
ctrl+r – reverse lookup pf previous commands
!! – repeat last command
exit – log out of current session