cheatsheets

Despite the beautiful interfaces found on most modern distros, knowledge of Linux command lines is a useful tool to have. Knowing these basic shortcuts can make you more efficient and supercharge your productivity, not to mention make coding at the terminal that much easier. Regardless of your current background knowledge of Linux, you can start using this list of useful Linux commands right away.

CommandDescriptionFile CommandslsList the content of the current directory.ls -RList the subdirectories recursively.ls -aList all the content, including hidden files.ls -lList the content and its information.ls -lhList all the files and folders with file sizes in human-readable format.pwdOutput the current directory that you are in.cd folder1Change the working directory to folder1.cdReturn to the $HOME directory.cd ..Go up a directory.cd –Return to the previous directory.cp source destinationCopy source to destination.cp -r source destinationCopy a folder recursively from source to destination.mv source destinationMove (or rename) a file from source to destination.rm file1Remove file1.rm -f file1Remove file1 without prompt.rm -r folderRemove a folder and its content recursively.mkdir foldernameCreate a new folder foldername.rmdir foldernameRemove an empty folder.touch file1Create a file named “file1” in the current working directory.file file1Show the file type of file1.cat file1 file2Concatenate file1 to file 2.cat > file1Concatenate standard input to file1.less file1View and paginate file1.head file1Show first 10 lines of file1.tail file1Show last 10 lines of file1.chmod 777 fileChange file permission of file to 777.chown user:group fileChange ownership of file to user and group group.chmod -R +rwx /path/to/fileChange the read, write and execute permission bits for all files and folders in the path directory.ln -s source destinationCreate a symbolic link from source to destination.ln -f source destinationCreate a hard link from source to destination and remove and existing links between the two files.File Encryption and Compressiongpg2 -c fileEncrypt file.gpg2 file.gpgDecrypt file.gpg.tar -cf archive.tar foo barCreate archive.tar from files foo and bar.tar -xf archive.tarExtract all files from archive.tar.gzip file1Compress file1 and rename it to file1.gz.gzip -d file1.gzDecompress file1.gz.tar cvzf archive.tar.gz foo barCreate a gunzip archive named “archive.tar.gz” using the files’ foo and bar.tar xvzf archive.tar.gzExtract a gunzip archive named “archive.tar.gz” and place the contents in the current working directory.GPG Key Managementgpg2 –full-gen-keyCreate a new GPG keypair.gpg2 –list-keysList all the available GPG keys in the system.gpg2 –edit-key [gpg email]Modify the properties of a GPG key that you currently use.gpg2 –export –armor –output filename.asc [gpg email]Create an importable ASCII public key for a GPG key that you use.gpg2 –export-secret-keys –armor –output filename.asc [gpg email]Create an importable ASCII private key for a GPG key that you use.gpg2 –import filename.ascImport a keyfile to your machine’s keyring.gpg2 –gen-revoke –armor –output filename.asc [gpg email]Generate a revocation certificate for a GPG key that you currently use.User and Group Managementuseradd -G email -s /bin/bash linuxCreate a new user named “linux”, include it to the group “email” and set its default shell to bash.groupadd -g 2222 extraCreate a new system group named “extra” with a Group ID of 2222.usermod -G extra linuxAdd the existing “linux” user to the “extra” group.groupmod -n super extraRename the group “extra” to “super”.userdel linuxDelete the user “linux” in the system.groupdel superDelete the group “super” in the system.Text Manipulationsed 11q sample.txtPrint the first 11 lines of the file “sample.txt”.sed -i s/string1/string2/g sample.txtReplace every instance of the word “string1” with “string2” in the “sample.txt” file.sed -i y/string1/strings2/g sample.txtTranspose the word “strings2” to every instance of the word “string1” in the “sample.txt” file.uniq input.txtPrint all the identical lines of text in the “input.txt” file.sort -r sample.txtReverse the line order of the “sample.txt” file.sort -R sample.txtRandomize the line order of the “sample.txt” file.sort -g sample.txtArrange the lines of the “sample.txt” file by absolute numerical order.sort -d sample.txtArrange the lines of the “sample.txt” file by alphabetical order.sort -M sample.txtArrange the lines of the “sample.txt” file by month order.cut -c a,e,i,o,u sample.txtRemove all the vowel characters in the “sample.txt” file and print the result to the terminal.cut -f field1,field2 sample.txtRemove the first two Tab-separated columns in the “sample.txt” file and print the result to the terminal.tr “A-Za-z” “A-Z” < sample.txtTranslate all the letters in the “sample.txt” file to uppercase.tr -cd “[:print:]” < sample.txtDelete all the control characters in the “sample.txt” file.System Commandsuname -aShow system and kernel.unameShow distribution.mountShow mounted filesystems.lsblkList all currently attached block storage devices.lsmodList all currently installed kernel modules in the system.lspciList all currently attached PCI and PCI-E devices in the machine.lsusbList all currently attached USB-type devices in the system.dateShow system date.uptimeShow system uptime.whoamiShow your username.usersDisplay who is online.groupsPrint all the names of the groups that the current user is a part of.apropos commandPrint all the matching manpages for the string “command”.man commandShow manual for command.info commandDisplay the appropriate info page for that particular command.!!Repeat the last command.exitLog out of current session.File Searching Commandsgrep pattern filesSearch for pattern in files.grep -iCase insensitive search.grep -rRecursive search.grep -vInverted search.grep -oShow matched part of file only.locate file1Find file1.whereis commandFind binary/source/manual for command.which appLocate a command for the app.look string file1Display any lines in file1 which contain string as a prefix.Process ManagementpsShow snapshot of processes.topShow real time processes.kill pidKill process with id pid.pkill nameKill process with name name.killall nameKill all processes with names beginning name.time commandRun the “command” program and print the amount of time the program ran to standard output.Disk Spacedf -hShow free space on mounted filesystems.du -h folderShow file usage of each folder in folder.du -hc folderShow the file usage for each folder in folder and print the total file size.du -sh folderShow the total file size of folder.fdisk -lShow disks partitions sizes and types (run as root).freeShow memory and swap usage.

Image credit: Christina Morillo via Pexels

TECH NEWS RELATED

‘Creepshow #1’ Review (Image Comics)

Written by Chris Burnham, Paul Dini, Stephen Langford | Art by Chris Burnham, John McCrea | Published by Image Comics Ah, Creepshow. People of a certain age, like me, have fond memories of the 1982 film Creepshow. How couldn’t you, it was a tongue-in-cheek horror film written by Stephen King, ...

View more: ‘Creepshow #1’ Review (Image Comics)

Maruti Suzuki Grand Vitara Vs Maruti Suzuki Brezza Price, Engine Specs, Dimensions & Features Comparison

Maruti Suzuki Grand Vitara Vs Maruti Suzuki Brezza Price, Engine Specs, Dimensions & Features Comparison In this Maruti Suzuki Grand Vitara vs Maruti Suzuki Brezza comparison, we’ll look at the variant-wise prices, engine specs and dimensions to help you decide which car you should buy. Maruti Suzuki Grand Vitara Vs ...

View more: Maruti Suzuki Grand Vitara Vs Maruti Suzuki Brezza Price, Engine Specs, Dimensions & Features Comparison

Nothing Ear (stick) gets spotted on FCC, packing Bluetooth 5.2 and more

Last week, Nothing showed the world its upcoming Ear (stick)’s case during London fashion week. It appears to be cylindrical with a Nothing logo printed in the middle. Besides that, it also has a transparent case that wraps around alongside a red tip on one end. After seeing the ...

View more: Nothing Ear (stick) gets spotted on FCC, packing Bluetooth 5.2 and more

Happy times with the Peugeot Django

This scooter leaves you yearning for a time that you haven’t even experienced

View more: Happy times with the Peugeot Django

Logitech G Pro X Superlight review: "great for players looking for that upper hand"

A great pro-level mouse that offers a luxury gaming experience without all of the flashy extras

View more: Logitech G Pro X Superlight review: "great for players looking for that upper hand"

Hero Xtreme 160R Stealth 2.0 Launch Price Rs 1.3 L – Apache Rival

Hero MotoCorp has kept the Xtreme 160R untouched in terms of mechanicals with visual and feature upgrades New Hero Xtreme 160R Stealth Edition 2.0 Hero MotoCorp is currently the highest-selling motorcycle manufacturer in India. With budget commuters like Splendor and HF Deluxe series, Hero is pushing on and on. For ...

View more: Hero Xtreme 160R Stealth 2.0 Launch Price Rs 1.3 L – Apache Rival

These Smart Kitchen Gadgets Are Actually Useful

Uutensil Out of all the rooms at home, it’s often easiest to get ahead of ourselves when picturing the futuristic kitchen. Saturday morning cartoons like The Jetsons have led us to expect a lot. We imagine robot arms flipping eggs while a drone drops oranges into a juicer and an AI ...

View more: These Smart Kitchen Gadgets Are Actually Useful

How is the iPhone 14 series performing? See what Analysts think

Since the official release of the iPhone 14 series, the smartphones have been attracting a lot of attention. The hardware and software performance are not the only aspects attracting attention. The market performance of this series is also a subject of interest. Apple analyst and investment bank Wedbush analyst, Dan Ives ...

View more: How is the iPhone 14 series performing? See what Analysts think

Xiaomi 12T series launching globally on 4 October

HBO drops the first full Last of Us trailer, featuring Clickers and plenty of grimness

Maruti Suzuki Grand Vitara Vs Competition — Dimensions, Specs And Comparison

BMW M5 review

Can You Buy Too Big of a PSU?

Nissan Leaf Electric Launch Planned For 18th Oct ?

Skullcandy’s Trio of Gaming Headsets Arrive at an Awesome Price

Nikola recalls all its electric trucks produced to date

Xiaomi Confirms October 4 Launch Event, 12T and 12T Pro Expected

E3 2023 Set to Be a Physical Event, Dates Announced

Xiaomi CIVI 2 Launched with Snapdragon 7 Gen 1 SoC, 120Hz Display Launched: Price, Specifications

Facelifted DS 3 E-Tense SUV gets 250-mile range

OTHER TECH NEWS

Top Car News Car News