The Ultimate Linux Commands Cheat Sheet for Beginners

If you’ve just stepped into the fascinating world of Linux, you’re in for a treat. The command-line interface might seem daunting initially, but trust me, it’s where the real magic happens.

This guide on “Linux Commands Cheat Sheet” will dive into a collection of essential Linux commands that will turn you into a command-line pro in no time.

Let’s get started!

Linux Commands Cheat Sheet

Linux Commands Cheat Sheet

1. pwd – Print Working Directory

So, you want to know where you are? Just type pwd and hit Enter. It will display the folder you’re currently hanging out in the Linux Operating system.

$ pwd
/home/username/Documents

2. ls – List

When you’re curious about what’s inside a folder, use ls. It’ll list all the files and folders in the current directory.

$ ls
file1.txt folder1 file2.txt

3. cd – Change Directory

Need to move around? cd is your friend. Type cd followed by the folder’s name, and you’re there.

$ cd Documents
$ cd ~

4. mkdir – Make Directory

Creating a new folder? Easy-peasy. Just type mkdir and the folder’s name, and voilĂ , a new directory is born.

$ mkdir NewFolder

5. cp – Copy and 6. mv – Move

Copying or moving files is a breeze with cp and mv. Tell Linux what to copy/move, and where to take it, and you’re good to go.

$ cp file1.txt /home/user
$ mv file2.txt NewFolder/

mv or move command is also used to rename files in Linux.

mv <old-name> <new-name> 

7. rm – Remove

Time to tidy up? rm helps you delete files or folders. Be careful though, there’s no undo button!

$ rm file1.txt

This is one of the most dangerous commands in Linux.

Mastering Files

1. cat – Concatenate

Want to peek inside a file? cat displays its content right in the terminal.

$ cat file2.txt
This is the content of file2.txt.

2. touch

Need a new file? Type touch and the file’s name. Boom, you’ve got an empty file.

$ touch newfile.txt

3. nano or vim

Editing text files? nano and vim are your text editors. They might look intimidating, but they’re powerful once you get the hang of them.

$ vi filename.txt
$ vim filename
$ nano filename

:wq! is the text you need to remember if you want to save the file and quit.

4. grep

Looking for something inside files or directories? Use grep (global regular expression print) to search them.

$ grep <pattern> filename

Peeking into Your System

1. uname

To know more about your system, just type uname. It’ll spill the beans on your system’s info.

$ uname -a

2. df – Disk Free

Running out of space? df will show you how much space you’ve got left on your disks.

$ df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/sda1       234G   34G  188G  15% /

3. top

Curious about what’s hogging your system resources? top gives you real-time info on processes and system usage. Best to know which process or applications are taking more CPU and memory.

$ top

This is also one of the most asked commands during the Linux interview.

4. free

Want to know how much memory is present in the Linux system and how much is currently used? Then use the free command.

$ free -m
$ free -g

5. find

The find command is designed to search through a specified directory and its subdirectories for files and directories that match your criteria. These criteria can be based on various attributes such as file name, size, modification time, permissions, and more.

$ find [starting_directory] [options] [expression]
$ find /home/user/documents -type f -name "*.txt"

Keeping Tabs on Processes

1. ps – Process Status

Type ps, and you’ll get a list of running processes. It’s like peeking behind the scenes.

$ ps aux

2. kill

Got a misbehaving process? Use kill to put it out of its misery.

$ kill PID
$ kill -9 PID
$ kill -15 PID

3. pidof

This command finds the process ID of a running program.

$ pidof <options> program

4. lsof

This command help in seeing the list of open files by the process.

$ lsof

User Matters

1. whoami

Wondering who’s using the terminal? whoami gives you the answer.

$ whoami
username

2. useradd and userdel

Need to add or remove users? useradd and userdel have you covered.

$ sudo useradd newuser
$ sudo userdel olduser

3. passwd

This command is commonly used to change the password of the user. You can also perform other actions on the user’s password like delete, expire, lock, unlock, etc. using this command.

$ passwd user

4. usermod

As the name indicates, this command is to modify the user’s account information like adding to an additional group, changing the user’s home location in Linux, adding or changing login shell, making the user inactive, etc.

$ usermod <options> user

Networking Adventures

1. ping

Testing your connection? ping helps you send a little message to another machine.

$ ping google.com

2. ifconfig or ip

Networking is a complex web, but ifconfig and ip can unravel the mystery by showing you network configurations.

$ ifconfig

3. ssh – Secure Shell

Want to connect to a remote server? ssh is your ticket to secure communication.

$ ssh username@hostname

4. netstat

This command shows network connections, routing tables, interface statistics, etc. You can also see currently used port in Linux with the help of this command.

$ netstat -tunlp

Taming Packages (For Debian/Ubuntu/RHEL/CentOs)

1. apt-get

Installing software on Linux? apt-get is the way to go. It manages software packages like a pro.

$ sudo apt-get install package_name

2. dpkg

More package management power? dpkg lets you install, remove, and manage packages efficiently.

$ sudo dpkg -i package.deb

3. rpm

Red Hat Package Manager or rpm is a popular command to manage packages in the Linux operating system. Install, remove, and update packages with RPM command

$ rpm -ivh package.rpm

4. yum

Yellowdog Updater Modified or yum is a package manager for RPM software packages. It is a more advanced alternative to rpm as it can install the dependencies automatically.

$ yum install package

Wrapping Up

There are lots of commands in Linux for everyday use and which one you use is your personal preference. Remember, practice makes perfect. So, don’t be afraid to experiment with these commands and explore more independently. As you become more comfortable with the command line, you’ll unlock the full potential of Linux.

We will keep this “Linux Commands Cheat Sheet” updated with more common and easy-to-use commands, so do not forget to bookmark this page.

FAQs

1. How to Get All Commands Used in Linux?

There are lots of Linux commands and all might not be present on your Linux machine.

If you want to check the commands that are present in your Linux machine, just check the below directories:

$ /bin
$ /sbin
$ /usr/bin
$ /usr/sbin

2. What is a Linux Cheat Sheet?

It’s a concise and handy reference document that compiles a collection of essential commands organized by categories. Whether you’re a seasoned Linux enthusiast or a newcomer, a Linux Commands cheat sheet provides quick access to commands’ names, explanations, and usage examples.

It’s like having a map to unlock the potential of your Linux journey, helping you troubleshoot, manage files, and navigate with ease.

3. How Can I Practice Linux Commands?

Practicing Linux commands is a journey best embarked upon with curiosity and hands-on experience. To kickstart your learning, consider creating a dedicated virtual environment using tools like VirtualBox or VMware.

You can install a Linux distribution of your choice, experimenting with various commands without the fear of damaging your main system.

Additionally, online platforms offer interactive sandboxes where you can practice real commands in a safe and guided environment. Remember, practice makes perfect, so start small, build your confidence, and gradually delve into more complex commands as you become comfortable.

4. What Are Admin Commands in Linux?

Admin commands, or administrative commands, are vital for proficiently managing a Linux system. These commands are essential for users with administrative privileges, allowing them to execute tasks that influence the system’s functionality. Admin commands encompass tasks like software installation, user management, process monitoring, and network configuration. While they empower system administrators, it’s crucial to use them responsibly and comprehend their system-wide implications.

Buy me a coffeeBuy me a coffee

Add Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.