Linux is a powerful operating system that gives users complete control over their computing environment. Whether you're a developer, system administrator, or just curious about the command line, knowing the essential Linux commands is crucial. After working with Ubuntu for the past 20 days, I've compiled a list of 60 commands that every Linux user needs to know. This guide will not only introduce you to these commands but also provide examples to help you understand how to use them effectively.
ls
✅What it does: Lists directory contents.
✅Example: ls -l displays detailed information about files and directories.
mkdir
✅What it does: Creates a new directory.
✅Example: mkdir testing creates a directory named testing.
cd
✅What it does: Changes the current directory.
✅Example: cd testing moves you to the testing directory.
pwd
✅What it does: Prints the current working directory.
✅Example: pwd outputs the full path of the directory you're in.
rm
✅What it does: Removes files or directories.
✅Example: rm file.txt deletes file.txt.
rmdir
✅What it does: Removes empty directories.
✅Example: rmdir empty_folder deletes empty_folder if it's empty.
cp
✅What it does: Copies files or directories.
✅Example: cp file1.txt file2.txt copies file1.txt to file2.txt.mv
✅What it does: Moves or renames files and directories.
✅Example: mv old_name.txt new_name.txt renames the file.
touch
✅What it does: Creates an empty file or updates the timestamp of an existing file.
✅Example: touch newfile.txt creates an empty file named newfile.txt.
cat
✅What it does: Concatenates and displays the content of files.
✅Example:cat file.txt
shows the content offile.txt
.
more
✅What it does: Views the content of files one page at a time.
✅Example:more file.txt
displays the file content page by page.less
✅What it does: Similar tomore
but allows backward movement.
✅Example:less file.txt
opens the file with the ability to scroll.head
✅What it does: Outputs the first few lines of a file.
✅Example:head -n 10 file.txt
shows the first 10 lines offile.txt
.tail
✅What it does: Outputs the last few lines of a file.
✅Example:tail -n 10 file.txt
shows the last 10 lines offile.txt
.echo
✅What it does: Displays a line of text or variables.
✅Example:echo "Hello, World!"
prints "Hello, World!" on the terminal.grep
✅What it does: Searches for patterns in files.
✅Example:grep 'search_term' file.txt
findssearch_term
infile.txt
.find
✅What it does: Searches for files and directories.
✅Example:find / -name file.txt
searches forfile.txt
starting from the root directory.locate
✅What it does: Quickly searches for files in the database.
✅Example:locate file.txt
findsfile.txt
in the file system.chmod
✅What it does: Changes file permissions.
✅Example:chmod 755 script.sh
sets the permission forscript.sh
.chown
✅What it does: Changes file ownership.
✅Example:chown user:group file.txt
changes the owner offile.txt
.ps
✅What it does: Displays currently running processes.
✅Example:ps aux
shows all running processes.kill
✅What it does: Terminates a process by PID.
✅Example:kill 1234
kills the process with PID 1234.top
✅What it does: Displays real-time system processes.
✅Example:top
opens the real-time process monitor.htop
✅What it does: An enhanced version oftop
.
✅Example:htop
gives a more user-friendly view of processes.df
✅What it does: Displays disk space usage.
✅Example:df -h
shows disk usage in human-readable format.du
✅What it does: Shows disk usage of files and directories.
✅Example:du -sh *
gives the size of each file and directory in the current directory.tar
✅What it does: Archives files.
✅Example:tar -czvf archive.tar.gz /path/to/directory
creates a compressed archive.gzip
✅What it does: Compresses files.
✅Example:gzip file.txt
compressesfile.txt
intofile.txt.gz
.
gunzip
✅What it does: Decompresses.gz
files.
✅Example:gunzip file.txt.gz
decompressesfile.txt.gz
.
zip
✅What it does: Creates a zip archive.
✅Example:zip archive.zip file1 file2
compressesfile1
andfile2
intoarchive.zip
.unzip
✅What it does: Extracts files from a zip archive.
✅Example:unzip archive.zip
extracts the contents ofarchive.zip
.wget
✅What it does: Downloads files from the internet.
✅Example:wget http://example.com/file.zip
downloadsfile.zip
.curl
✅What it does: Transfers data from or to a server.
✅Example:curl -O http://example.com/file.zip
downloadsfile.zip
.
ssh
✅What it does: Connects to a remote server via SSH.
✅Example:ssh user@host
connects to a remote server.
scp
✅What it does: Securely copies files between servers.
✅Example:scp file.txt user@host:/path/to/destination
copiesfile.txt
to a remote server.rsync
✅What it does: Synchronizes files and directories between two locations.
✅Example:rsync -avz /source/ /destination/
syncs the source directory to the destination.history
✅What it does: Shows the command history.
✅Example:history | grep 'search_term'
finds a command in your history.alias
✅What it does: Creates shortcuts for commands.
✅Example:alias ll='ls -la'
creates a shortcut forls -la
.unalias
✅What it does: Removes an alias.
✅Example:unalias ll
removes thell
alias.nano
✅What it does: Opens the nano text editor.
✅Example:nano file.txt
opensfile.txt
in nano.vim
✅What it does: Opens the vim text editor.
✅Example:vim file.txt
opensfile.txt
in vim.
apt-get
✅What it does: Installs, upgrades, or removes packages.
✅Example:apt-get install package_name
installs a package.
apt
✅What it does: A more user-friendly interface for `apt-get
Conclusion
Linux commands are the building blocks for managing and operating a Linux-based system like Ubuntu. Whether you're a beginner or an experienced user, mastering these essential commands will empower you to navigate, manage, and troubleshoot your system efficiently. From basic file manipulation to advanced process management, these 40+ commands provide a strong foundation to help you unlock the full potential of Linux. As you continue to explore and practice these commands, you'll find that the command line is not just a powerful tool but also an indispensable part of your daily workflow. Keep experimenting, keep learning, and soon these commands will become second nature as you become a more proficient and confident Linux user.
Top comments (2)
If you mention vim, immediately describe how to exit it :)
Well, nano is known, but its style is horrible for many people including me. If I need non-vi-style editor in terminal, I install joe and remove nano.
Let's always list
mc
as a sample tool to navigate FS and alleviate one-shot tasks.gunzip
is justgzip -d
, no need for a separate item.apt-get
is Debian style. Equivalents asdnf
,yum
deserves listing.May be extended, but if the whole list split into sections.
Nice! With du, you could also use
tree -hs
which will branch all files in a hierarchy and give human readable sizes.