Linux Commands Every User Should Know

Linux Commands

Here are essential Linux commands and how to use them:

  1. pwd command

Use the pwd command to find out which directory (folder) you are currently in. The command returns the absolute path of your current location, which typically begins with a slash (/), for example /home/username.

  1. cd command

Use cd to navigate the Linux filesystem. Depending on your current directory, you can enter either a relative directory name or the full path.

For example, if you are in /home/username/Documents and want to go to the Photos subdirectory, run cd Photos. To jump directly to a different directory such as /home/username/Movies, use cd /home/username/Movies.

There are useful shortcuts: cd .. moves up one level, cd alone returns you to your home directory, and cd – switches back to the previous directory. Note that the shell is case-sensitive, so type directory names exactly.

  1. ls command

ls lists the contents of a directory. By default it shows the current directory. To view another directory, pass its path, for example: ls /home/username/Documents.

  1. cat command

cat is commonly used to display a file’s contents to standard output. Use cat filename.txt to print the contents of a text file to the terminal.

  1. cp command

Use cp to copy files from one location to another. For example, cp sample.jpg /home/username/Pictures copies sample.jpg into the Pictures directory.

  1. mv command

mv moves files or renames them. Its usage is similar to cp. For example, mv file.txt /home/username/Documents moves a file to Documents. To rename a file, use mv oldname.ext newname.ext.

  1. mkdir command

mkdir creates a new directory. For example, mkdir Music creates a directory named Music.

  1. rmdir command

Use rmdir to remove a directory, but note that rmdir only deletes empty directories.

  1. rm command

rm deletes files and, with options, directories and their contents. To remove a directory and everything inside it, use rm -r (recursive).

  1. touch command

touch creates new empty files from the command line. For example, to create an HTML file in Documents, run touch /home/username/Documents/Web.html.

  1. locate command

locate quickly finds files by name, similar to a search tool. Use the -i option for case-insensitive searches. Use wildcards like * for multi-word patterns, e.g. locate -i school*notes will find files that include “school” and “notes” regardless of case.

  1. find command

Like locate, find searches for files but is used to search within a specific directory tree. For example, find /home/ -name notes.txt searches for a file named notes.txt under /home and its subdirectories.

  1. grep command

grep searches for text patterns inside files. For example, grep blue notes.txt searches for the word “blue” inside notes.txt and prints matching lines.

  1. sudo command

sudo stands for “SuperUser Do” and grants elevated (administrator/root) privileges for commands that require them. Use it carefully—incorrect use can cause system errors.

  1. df command

df reports disk space usage for filesystems in percentages and kilobytes. To display sizes in megabytes, use df -m.

  1. du command

du (Disk Usage) shows how much space a file or directory consumes. By default it reports in disk blocks; add -h for human-readable sizes (bytes, KB, MB).

  1. head command

head displays the first lines of a text file. By default it shows the first ten lines. To show a different number, use head -n 5 filename.ext to see the first five lines.

  1. tail command

tail is similar to head but shows the last lines of a file; by default it displays the last ten lines.

  1. diff command

diff compares two files line by line and lists differences. Programmers often use it to identify changes without rewriting whole files. Basic usage: diff file1.ext file2.ext.

  1. tar command

tar archives multiple files into a single tarball. A tarball is an archive similar to zip; compression is optional. tar can create archives, append files, list contents, and extract files—review practical examples to learn specific options.

  1. chmod command

chmod changes read, write, and execute permissions for files and directories. Its options and numeric modes can be complex; consult a dedicated chmod guide to learn proper usage.

  1. chown command

Every file has an owner. Use chown to change a file’s owner. For example, chown newuser file.ext assigns ownership of file.ext to newuser.

  1. jobs command

jobs lists shell-started jobs and their statuses. A job is any process initiated by the shell.

  1. kill command

If a program is unresponsive, use kill to send it a signal requesting termination. Two common signals are:

  • SIGTERM (15) — politely asks a process to stop, allowing it to save state. This is the default signal if none is specified.
  • SIGKILL (9) — forcefully and immediately terminates a process; unsaved data may be lost.

To use kill you need the process ID (PID). If you don’t know it, run ps ux to list running processes. Then run kill [signal option] PID, for example kill -9 1234.

  1. ping command

ping checks connectivity to a server and measures response time. For example, ping google.com tests whether you can reach Google and reports latency.

  1. wget command

wget downloads files from the Internet. Use wget followed by a file URL to download it from the command line.

  1. uname command

uname (Unix Name) displays system information such as the machine name, operating system, and kernel version, which can help identify your environment.

  1. top command

top is similar to Task Manager on Windows: it shows running processes and their CPU usage, making it useful for monitoring system resources and identifying resource-heavy programs.

  1. history command

The history command shows a list of previously executed commands, which is helpful when you want to repeat or review past actions.

  1. man command

If you forget a command’s syntax or options, use man to read its manual page from the shell. For example, man tail displays the usage instructions for the tail command.

Author: Samed Gül