Tuesday, January 7, 2020

Linux Cheat Sheet


FILES NAVIGATING 


ls : Directory Listing( list all files/folders on current directory)
ls -l : Formatted listing
ls -la : Formatted listing including hidden files
cd dir : Change directory to dir( dir will be directory name)
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 a directory dir
rm file : Delete file
rm -f dir : Force Remove File
rm -r dir : Delete directory dir
rm -rf dir : Remove directory dir
cp file1 file2 : copy file1 to file2
mv file1 file2 : Rename file1 to file2
mv file1 dir/file2 : move file1 to dir as file2
touch file : create or update file
cat file: output contents of file
cat  >file : Write Standard input into file
cat >>file : Append Standard input into file 
tail -f file : Output Contents of file as it grows


NETWORKING

ping host : ping host
whois domain : get whois for domain
dig domain : get DNS for domain
dig -x host : Reserve lookup host
wget file : Download file 
wget -c file : Continue stopped download
wget -r url : recursively download files from URL
Curl url : Outputs the webpage from URL
Curl -o meh.html url : Writes the page to meh.html
ssh user@host : connect to host as User
ssh -p port user@host : Connect using Port
ssh -D user@host : Connect & use bind port

PROCESSES

ps : Display currently Active processes
ps aux: Detailed Outputs
kill pid :  kill process with process id(pid)
killall proc : kill ALL processes named proc

SYSTEM INFO

date : Show current date/time
uptime: Show Uptime
whoami : Who you're logged in as
w : Display Who is online
cat/proc/cpuinfo : Display CPU info
cat/proc/meminfo : Display Memory Info
free : Show Memory and Swap Usage
du : Show directory space usage
du -sh : Displays readable sizes in GB
df : Show disk Usage
uname -a : Show Karnel Config

PERMISSIONS

chmod octal file : Change Permissions of the file

        4 - Read ( R) 
        2 - Write (W)
        1 - Execute (X) 

ORDER -- OWNER/GROUP/WORLD(EVERYONE)

 chmod 777 - RWX for Everyone
 chmod 755 - RW for OWNER, RX for group WORLD( EVERYONE) 


OTHERS

grep pattern files : Search in files for Pattern
grep -r pattern dir : Search for pattern Recursively in dir
locate file : Find ALL instances of file
whereis app : Show possible locations of app
man command : show manual page for command


COMPRESSING

tar cf file.tar files : tar files into files.tar
tar xf file.tar : untar into current directory
tar tf file.tar : show contents of Archive

Options

c: create archive                            j : bzip2 compression
t: table of contents                        w : ask for confirmation
x: extract                                      k : do not overwrite
z: use zip/gzip                               T: files from file
f: specify filename                          v : vorbose






Linux Cheat Sheet

FILES NAVIGATING  ls : Directory Listing( list all files/folders on current directory) ls -l : Formatted listing ls -la : Forma...