Philosophy of using command line is that input and output files are files.
Basic Commands:
Correct grammar of command is: verb adverb object
where adverb is the flag you add to a command e.g -hl in ls -hl
To view the flags for a command use man e.g man ls
cd -go back to previous directory you were inlslist files in a directoryls -hlmore human readable version ofls -lls -torder by modification date, newest first
cpcopy a filecp data1 data3copies adata1file todata3
cp -rto copy a folder with files insidermremove a filemvchanges a file namecatoutput contents of the fileheadoutput top part of the file- use
-nflag to choose the number of lines e.g-5
- use
tailprint top part of the file
lessopens a pager to view a file- within the pager can use
/to search in the file then pressnto search for the next file.
- within the pager can use
grepis used to search a file e.ggrep "fish" king-lear.txt- to count the number of lines in a text file add
-ctag grep -c "fish" king-lear.txt - to be case insensitive use
-i - use regular expressions with grep for example wildcard
* - search in all files and files in subdirectories with
-rtag
Shell scripts are just a text file where we can store linux commands
- to count the number of lines in a text file add
Useful
- Making google chrome the default application to open
.pdfextensions, run in terminal:
1
xdg-mime default google-chrome.desktop application/pdf