DEV Community

Cover image for 40+ Linux Commands You Need to Know: The Ultimate Guide for Ubuntu Users
Ayush kumar
Ayush kumar

Posted on

40+ Linux Commands You Need to Know: The Ultimate Guide for Ubuntu Users

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.

  1. ls
    ✅What it does: Lists directory contents.
    ✅Example: ls -l displays detailed information about files and directories.
    Image description

  2. mkdir
    ✅What it does: Creates a new directory.
    ✅Example: mkdir testing creates a directory named testing.
    Image description

  3. cd
    ✅What it does: Changes the current directory.
    ✅Example: cd testing moves you to the testing directory.
    Image description

  4. pwd
    ✅What it does: Prints the current working directory.
    ✅Example: pwd outputs the full path of the directory you're in.
    Image description

  5. rm
    ✅What it does: Removes files or directories.
    ✅Example: rm file.txt deletes file.txt.
    Image description

  6. rmdir
    ✅What it does: Removes empty directories.
    ✅Example: rmdir empty_folder deletes empty_folder if it's empty.
    Image description

  7. cp
    ✅What it does: Copies files or directories.
    ✅Example: cp file1.txt file2.txt copies file1.txt to file2.txt.

  8. mv
    ✅What it does: Moves or renames files and directories.
    ✅Example: mv old_name.txt new_name.txt renames the file.
    Image description

  9. 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.
    Image description

  10. cat
    ✅What it does: Concatenates and displays the content of files.
    ✅Example: cat file.txt shows the content of file.txt.
    Image description

  11. 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.

  12. less
    ✅What it does: Similar to more but allows backward movement.
    ✅Example: less file.txt opens the file with the ability to scroll.

  13. head
    ✅What it does: Outputs the first few lines of a file.
    ✅Example: head -n 10 file.txt shows the first 10 lines of file.txt.

  14. tail
    ✅What it does: Outputs the last few lines of a file.
    ✅Example: tail -n 10 file.txt shows the last 10 lines of file.txt.

  15. echo
    ✅What it does: Displays a line of text or variables.
    ✅Example: echo "Hello, World!" prints "Hello, World!" on the terminal.

  16. grep
    ✅What it does: Searches for patterns in files.
    ✅Example: grep 'search_term' file.txt finds search_term in file.txt.

  17. find
    ✅What it does: Searches for files and directories.
    ✅Example: find / -name file.txt searches for file.txt starting from the root directory.

  18. locate
    ✅What it does: Quickly searches for files in the database.
    ✅Example: locate file.txt finds file.txt in the file system.

  19. chmod
    ✅What it does: Changes file permissions.
    ✅Example: chmod 755 script.sh sets the permission for script.sh.

  20. chown
    ✅What it does: Changes file ownership.
    ✅Example: chown user:group file.txt changes the owner of file.txt.

  21. ps
    ✅What it does: Displays currently running processes.
    ✅Example: ps aux shows all running processes.

  22. kill
    ✅What it does: Terminates a process by PID.
    ✅Example: kill 1234 kills the process with PID 1234.

  23. top
    ✅What it does: Displays real-time system processes.
    ✅Example: top opens the real-time process monitor.

  24. htop
    ✅What it does: An enhanced version of top.
    ✅Example: htop gives a more user-friendly view of processes.

  25. df
    ✅What it does: Displays disk space usage.
    ✅Example: df -h shows disk usage in human-readable format.

  26. 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.

  27. tar
    ✅What it does: Archives files.
    ✅Example: tar -czvf archive.tar.gz /path/to/directory creates a compressed archive.

  28. gzip
    ✅What it does: Compresses files.
    ✅Example: gzip file.txt compresses file.txt into file.txt.gz.
    Image description

  29. gunzip
    ✅What it does: Decompresses .gz files.
    ✅Example: gunzip file.txt.gz decompresses file.txt.gz.
    Image description

  30. zip
    ✅What it does: Creates a zip archive.
    ✅Example: zip archive.zip file1 file2 compresses file1 and file2 into archive.zip.

  31. unzip
    ✅What it does: Extracts files from a zip archive.
    ✅Example: unzip archive.zip extracts the contents of archive.zip.

  32. wget
    ✅What it does: Downloads files from the internet.
    ✅Example: wget http://example.com/file.zip downloads file.zip.

  33. curl
    ✅What it does: Transfers data from or to a server.
    ✅Example: curl -O http://example.com/file.zip downloads file.zip.
    Image description

  34. ssh
    ✅What it does: Connects to a remote server via SSH.
    ✅Example: ssh user@host connects to a remote server.
    Image description

  35. scp
    ✅What it does: Securely copies files between servers.
    ✅Example: scp file.txt user@host:/path/to/destination copies file.txt to a remote server.

  36. rsync
    ✅What it does: Synchronizes files and directories between two locations.
    ✅Example: rsync -avz /source/ /destination/ syncs the source directory to the destination.

  37. history
    ✅What it does: Shows the command history.
    ✅Example: history | grep 'search_term' finds a command in your history.

  38. alias
    ✅What it does: Creates shortcuts for commands.
    ✅Example: alias ll='ls -la' creates a shortcut for ls -la.

  39. unalias
    ✅What it does: Removes an alias.
    ✅Example: unalias ll removes the ll alias.

  40. nano
    ✅What it does: Opens the nano text editor.
    ✅Example: nano file.txt opens file.txt in nano.

  41. vim
    ✅What it does: Opens the vim text editor.
    ✅Example: vim file.txt opens file.txt in vim.
    Image description

  42. apt-get
    ✅What it does: Installs, upgrades, or removes packages.
    ✅Example: apt-get install package_name installs a package.
    Image description
    Image description

  43. apt
    ✅What it does: A more user-friendly interface for `apt-get
    Image description
    Image description

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)

Collapse
 
netch80 profile image
Valentin Nechayev

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 just gzip -d, no need for a separate item.

apt-get is Debian style. Equivalents as dnf, yum deserves listing.

May be extended, but if the whole list split into sections.

Collapse
 
martinbaun profile image
Martin Baun • Edited

Nice! With du, you could also use

tree -hs

which will branch all files in a hierarchy and give human readable sizes.