Linux Terminal Cheat Sheet Cheat Sheet by hamza391 via cheatography.com/52792/cs/14298/
Rebooting and Shutting Down Finding Files Exploring the FileSystem shutdown at 10:00 $ sudo shutdown -h Searching for files and find /usr -name Changes your current directory to the cd / 10:00 directo ries named "g cc" gcc root (/) directory (or path you supply) shutdown now $ sudo shutdown -h now Searching only for find /usr -type d List the contents of the present working ls restart at 10:00 $ sudo shutdown -r directories named "gcc": -name gcc directory 10:00 Searching only for regular $ find /usr -type List all files including hidden files and ls – restart now $ sudo shutdown -r now files named "gcc" f -name gcc directories (those whose name start with a *To find files based on time find / -ctime n . ) with message $ sudo shutdown -h created "+_ n" days Displays a tree view of the filesystem tree "S hut ting down for 10:00 "S hut ting down for scheduled scheduled To find files based on size $ find / -size n mainten ance. mainten anc e." +- n Directo ries
Another good use of find is being able to run to create a directory. mkdir Locate applica tion commands on the files that match your search create a sample directory named mkdir locate applica tion only which "a ppl ica tion criteria. The -exec option is used for this sampdir under the current sampdir name" purpose. directory, To find and remove all files that end with .swp: locates applica tion , whereis create a sample directory called mkdir source and man "a ppl ica tion name" sampdir under /usr /usr/sa m $ find -name "* .sw p" -exec rm {} ’;’ pdir. *mtime for modifie d/w ritten time Locate / Find atime for access time/read time Removing a directory * rmdir The locate utility program performs a search To remove a directory and all of its rm -rf through a previously constru cted database of Accessing Directo ries contents files and directo ries on your system, matching Displays the present working pwd * for rmdir The directory must be empty or it will all entries that contain a specified character directory fail string * usage sample for rmdir and rm -rf is same as updatedb to update the database Change to your home directory cd ~ or mkdir can use grep program as a filter; grep will print cd only the lines that contain one or more Change to parent directory cd .. Renaming / removing directory specified strings Change to previous directory cd - $ locate zip | grep bin Rename a directory mv
Remove an empty directory rmdir
Forcefully remove a directory rm -rf recursi vely
By hamza391 Not published yet. Sponsored by Readability-Score.com cheatography.com/hamza391/ Last updated 13th January, 2018. Measure your website readability! Page 1 of 2. https://readability-score.com Linux Terminal Cheat Sheet Cheat Sheet by hamza391 via cheatography.com/52792/cs/14298/
Basic Packagaing Commands Viewing Files Removin g/R ena ming file
Install package dpkg --install for viewing files that are not cat Rename a file mv
foo.deb very long; it does not provide Remove a file rm any scroll- back. Install package, apt-get install foo Forcefully remove a file rm –f depende ncies o look at a file backwards, tac Interac tively remove a file rm –i Remove package dpkg --remove starting with the last line foo.deb Used to view larger files less (/ for
Remove package, apt-get forwad and ? depende ncies autoremove foo for backward)
Update package dpkg --install Used to print the last 10 lines tail foo.deb Used to print the first 10 lines head
Update package, apt-get install foo Used to print the last X lines tail -n X or tail dependencies -X Update entire system apt-get dist- Used to print the first X lines head -n X or up grade head -X
Show all installed dpkg --list packages File Linking
Get informa tion on dpkg --listf iles foo Hardlink file1 and file2 $ ln file1 file2 package Softlink file1 and file2 $ ln -s file1 file2 Show packages named apt-cache search foo foo New file / change time of file Show all available apt-cache Create newfile $ touch packages dumpavail foo "f ile nam e" What package is file part dpkg --search file sets the "m yfi le" file's time stamp $ touch -t of? to 4 p.m., March 20th (03 20 03201600 1600). myfile
By hamza391 Not published yet. Sponsored by Readability-Score.com cheatography.com/hamza391/ Last updated 13th January, 2018. Measure your website readability! Page 2 of 2. https://readability-score.com