Introduction -
In the recent few weeks, I have started using Linux on a daily basis. As we all know, someone using Linux needs to have a good grasp on the commands. Hence, I thought of preparing something similar to a cheatsheet for some of the most used commands -
FILE & DIRECTORIES -
ls
- directory listing (list all files/folders on current dir)ls -l
- formatted listingls -la
- formatted listing including hidden filescd dir
- change directory to dir (dir will be directory name)cd ..
- change to the parent directorycd ../dir
- change to dir in the parent directorycd
- change to the home directorypwd
- show current directorymkdir dir
- create a directory dirrm file
- delete a filerm -f dir
- force remove the filerm-r dir
- delete directory dirrm-rf dir
- remove directory dircp file1 file2
- copy file1 to file2mv file1 file2
- rename file1 to file2mv file1 dir/file2
- move file1 to dir as file2touch file
- create or update filecat file
- output contents of the filecat > file
- write standard input into the filecat >> file
- append standard input into the filetail -f file
- output contents of the file as it grows
NETWORKING -
ping host
- ping the serverwho is domain
- get whois for domaindig domain
- get DNS for domaindig -x host
- reserve lookup hostwget file
- download filewget -c file
- continue stopped downloadwget -r url
- recursively download files from urlcurl url
- outputs the webpage from urlcurl -o meh.html url
- writes the page to meh.htmlssh user@host
- connect to host as userssh -p port user@host
- connect using portssh -D user@host
- connect & use bind port
PROCESSES -
ps
- display currently active processesps aux
- detailed outputskill pid
- kill process with process id (pid)killall proc
- kill all processes named proc
SYSTEM INFO -
date
- show current date/timeuptime
- show uptimewhoami
- who you're logged in asw
- display who is onlinecat /proc/cpuinfo
- display CPU infocat /proc/meminfo
- memory infofree
- show memory and swap usagedu
- show directory space usagedu -sh
- displays readable sizes in GBdf
- show disk usageuname -a
- show kernel config
COMPRESSING -
tar cf file.tar files
- tar files into file.tartar xf file.tar
- untar into the current directorytar tf file.tar
- show contents of the archive
options:
c - create an archive
t - table of contents
x - extract
z - use zip/gzip
f - specify the filename
j - bzip2 compression
w - ask for confirmation
k - do not overwrite
T - files from the file
v - verbose
PERMISSIONS -
chmod octal file
- change permissions of file
4 - read (r)
2 - write (w)
1 - execute (x)
order: owner/group/world
chmod 777 - rwx for everyone
chmod 555 - rw for owner / rx for group
SOME OTHERS -
grep pattern files
- search in files for patterngrep -r pattern dir
- search for pattern recursively in dirlocate file
- find all instances of filewhereis app
- show possible location of appman command
- show manual page for command