Linux CLI: January 8, 2021 1:37 PM

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

Linux CLI

January 8, 2021 1:37 PM

• File/Dir Manipulation
○ pwd - present work directory
○ mkdir, rmdir, mv, cp, rm - file/dir manipulation
 ../ -> refers to directory above pwd
 . -> current dierctory
 eg: mv ../ file* . -> moves all files starting with name 'file' from parent directory to
current directory
○ touch - update, date/time stamp of file
 if file doesn’t exist, creates it
○ globbing - using wild characters to access group of files
 file* - all files starting with 'file' and any character after that
 file? - all files starting with 'file' and one character after that
○ locate - to locate a file anywhere in the system
 updatedb - to update the file index before using locate
○ cat - display file contents
 actually concatenates and then displays multiple files
○ grep - search/filter file content
 combined with | for more utility
□ cat /etc/groups | grep ubuntu
○ >>/> /</<< - redirect contents to a file
 > - to create new file or replace existing file with same name
 >> - append existing file, else create new

□ wget google.coom 2> errorfile.txt - redirecting from stderr to a file


 $ mysql -u root -p < mydatabase.sql
○ head/tail - show first/last 10 lines of the file contents
○ cut - cut a line according to a specified delimiter and select any particular field
 cut -d: -f3 /etc/group
○ sort - sort ascending (-n) or descending (-rn)
 cut -d: -f3 /etc/group | sort -n
○ wc - counts lines, words, characters in a file
○ echo - prints the following string or value of variable
○ wget - fetch data from web in the background and store it to the specified location
○ chmod - change the file attributes
• Archives
○ tar - tape archive - for compression
 latest.tar.gz - archive named 'latest' is a tar archive compressed using gz algorithm

Linux Page 1
 latest.tar.gz - archive named 'latest' is a tar archive compressed using gz algorithm
 tar xzf latest.tar.gz
□ c/x - compress/decompress
□ z - ziped file
□ f - filename follows immediately
○ unzip - for zip archives
○ gzip - when z option is dropped in tar - less compression
○ bzip - uses Burrows-Wheeler transform compression algo

Linux Page 2

You might also like