Introduction
The Linux operating system family is a group of free and open-source Unix systems. They consist of Red Hat, Arch Linux, Ubuntu, Debian, openSUSE, and Fedora. You must use a shell when using Linux, an application that allows you access to the system’s features. The majority of Linux distributions have a graphical user interface (GUI), which makes them user-friendly for beginners. I advise using the command-line interface (CLI), as it is speedier and gives you more control. By putting commands into the CLI, tasks that take many steps on the GUI may be completed in a matter of seconds.
This post covers the commands you need first: moving around, working with files, reading them, finding commands, and checking who you are and which groups you belong to. Networking, processes and scripting each have their own cheatsheet, linked at the end.
What is a Linux command?
An application or tool that runs on the CLI, a console that communicates with the system via text and processes, is known as a Linux command. It resembles Windows’ Command Prompt program in many ways. By hitting Enter at the end of the line, Linux commands are run on the terminal. You may use commands to carry out a range of operations, including managing users, installing packages, and manipulating files.
The general syntax of a Linux command is as follows:
CommandName [flag(s)] [parameter(s)]
- CommandName is the name of the command you want to run.
- Flag(s) are optional arguments that modify the behavior of the command.
- Parameter(s) are required arguments that specify the command’s input.
Note
Remember that case affects the syntax of every Linux command.
File management
Every system administrator should be familiar with the very basic commands listed in this section. This collection of Linux commands for managing files is undoubtedly incomplete, but it can serve as a starting point and cover the majority of simple to complicated situations.
pwd
The pwd command is used to print the current working directory. The working directory is the directory you are currently in. The output of the pwd command is the path to the working directory.
# Print the current working directorypwdpwd flags
-L- If the current working directory is a symbolic link, print the path of the symbolic link.-P- If the current working directory is a symbolic link, print the path of the symbolic link’s target.
# Print the current working directorypwd -L
# Print the current working directorypwd -Pls
The ls command lists a system’s files and directories. It will display the contents of the current working directory when run without a flag or argument.
# List the contents of the current working directorylsls flags
-a- List all files, including hidden files.-l- List files in long format.-h- List files in human-readable format.-r- List files in reverse order.-t- List files by the time they were last modified.
# List all files, including hidden filesls -a
# List files in long formatls -l
# List files in human-readable formatls -h
# List files in reverse orderls -r
# List files by the time they were last modifiedls -tcd
The cd command is used to change the current working directory. It takes a directory as an argument. The output of the cd command is the new working directory.
# Change the current working directory to the home directorycd ~mkdir
The mkdir command is used to create a new directory. It takes a directory name as an argument. The output of the mkdir command is the newly created directory.
# Create a new directory named "new-directory"mkdir new-directorymkdir flags
-p- Create parent directories as needed.
# Create a new directory named "new-directory" and its parent directoriesmkdir -p new-directorytouch
The touch command is used to create a new file. It takes a file name as an argument. The output of the touch command is the newly created file.
# Create a new file named "new-file"touch new-filetouch flags
-a- Change the access time of the file.-m- Change the modification time of the file.-t- Set the access and modification times to a given timestamp, in[[CC]YY]MMDDhhmm[.ss]format.
# Change the access time of the filetouch -a new-file
# Change the modification time of the filetouch -m new-file
# Set both times to 1 January 2026, 12:00touch -t 202601011200 new-filecp
The cp command is used to copy files and directories. It takes the source and destination as arguments. The output of the cp command is the copied file or directory.
# Copy the file "file" to the directory "directory"cp file directorycp flags
-r- Copy directories recursively.
# Copy the directory "directory" to the directory "new-directory"cp -r directory new-directorymv
The mv command is used to move files and directories. It takes the source and destination as arguments. The output of the mv command is the moved file or directory.
# Move the file "file" to the directory "directory"mv file directorymv flags
-i- Prompt before overwriting an existing file.-f- Force the move of a file, even if it already exists.-u- Move a file only if the source file is newer than the destination file.
# Move the file "file" to the directory "directory" and prompt before overwriting an existing filemv -i file directory
# Move the file "file" to the directory "directory" and force the move of a file, even if it already existsmv -f file directory
# Move the file "file" to the directory "directory" and move a file only if the source file is newer than the destination filemv -u file directoryrm
The rm command is used to remove files and directories. It takes the file or directory as an argument. The output of the rm command is the removed file or directory.
# Remove the file "file"rm filerm flags
-r- Remove directories and their contents recursively.-f- Force remove files without prompting for confirmation.
# Remove the directory "directory" and its contents recursivelyrm -r directory
# Remove the file "file" without prompting for confirmationrm -f filermdir
The rmdir command is used to remove empty directories. It takes the directory as an argument. The output of the rmdir command is the removed directory.
# Remove the directory "directory"rmdir directoryrmdir flags
-p- Remove parent directories as needed.
# Remove the directory "directory" and its parent directoriesrmdir -p directorycat
The cat command is used to display the contents of a file. It takes a file as an argument. The output of the cat command is the contents of the specified file.
# Display the contents of the file "file"cat filecat flags
-n- Number all output lines.
# Display the contents of the file "file" and number all output linescat -n filemore
The more command is used to display the contents of a file. It takes a file as an argument. The output of the more command is the contents of the specified file.
# Display the contents of the file "file"more filemore flags
-d- Show a “[Press space to continue, ‘q’ to quit.]” prompt instead of ringing the bell on an invalid key.
# Display the contents of the file "file" with a help promptmore -d fileless
The less command is used to display the contents of a file. It takes a file as an argument. The output of the less command is the contents of the specified file.
# Display the contents of the file "file"less fileless flags
-N- Display the contents of the file “file” and number all output lines.
# Display the contents of the file "file" and number all output linesless -N filehead
The head command is used to display the first 10 lines of a file. It takes a file as an argument. The output of the head command is the first 10 lines of the specified file.
# Display the first 10 lines of the file "file"head filehead flags
-n- Display the first n lines of the file “file”.
# Display the first 5 lines of the file "file"head -n 5 filetail
The tail command is used to display the last 10 lines of a file. It takes a file as an argument. The output of the tail command is the last 10 lines of the specified file.
# Display the last 10 lines of the file "file"tail filetail flags
-n- Display the last n lines of the file “file”.
# Display the last 5 lines of the file "file"tail -n 5 fileFinding files and directories
locate finds files by name from a prebuilt index. I also use which a lot, since it gives the binary’s full path, which you need whenever you must run a binary by its complete path.
locate
The locate command is used to find files and directories. It takes a file or directory name as an argument. The output of the locate command is the files and directories that match the specified criteria.
# Find all files and directories in the current directory with the name "file"locate filelocate flags
-i- Find files and directories with the specified name, ignoring case.
# Find all files and directories in the current directory with the name "file" ignoring caselocate -i filewhich
The which command is used to find the location of a command. It takes a command as an argument. The output of the which command is the location of the specified command.
# Find the location of the command "command"which commandwhich flags
-a- Find all locations of the specified command.
# Find all locations of the command "command"which -a commandwhereis
The whereis command is used to find the location of a command. It takes a command as an argument. The output of the whereis command is the location of the specified command.
# Find the location of the command "command"whereis commandwhereis flags
-b- Search only for the binary, not the man pages or source files.
# Find only the binary of the command "command"whereis -b commandCheck user information
These are a few of the commands we employ to verify the details of the most recent person to log in, as well as a few others to obtain further information regarding an existing user.
whoami
The whoami command is used to display the current user. It takes no arguments. The output of the whoami command is the current user.
# Display the current userwhoamiwho
The who command is used to display the current users. It takes no arguments. The output of the who command is the current users.
# Display the current userswhowho flags
-u- Also show each user’s idle time and login process ID.
# Display the logged-in users with idle time and process IDwho -uw
The w command is used to display the current users. It takes no arguments. The output of the w command is the current users.
# Display the current usersww flags
-u- Ignore the username when working out the current process and CPU times.
# Display the logged-in users, ignoring the username for process and CPU timesw -uid
The id command is used to display the current user. It takes no arguments. The output of the id command is the current user.
# Display the current useridid flags
-u- Print only the effective user ID.
# Print the numeric user ID of the current userid -ugroups
The groups command is used to display the current user’s groups. It takes no arguments. The output of the groups command is the current user’s groups.
# Display the current user's groupsgroupsManaging users and groups
These commands remove users, change passwords, and rename or renumber groups.
userdel
The userdel command is used to delete a user. It takes a username as an argument. The output of the userdel command is the user that was deleted.
# Delete a user with the username "user"userdel useruserdel flags
-r- Also remove the user’s home directory and mail spool.
# Delete the user "user" along with their home directoryuserdel -r userpasswd
The passwd command is used to change a user’s password. It takes a username as an argument. The output of the passwd command is the user’s password that was changed.
# Change a user's password with the username "user"passwd userpasswd flags
-d- Change a user’s password with the specified username and delete the password.-e- Change a user’s password with the specified username and expire the password.-l- Change a user’s password with the specified username and lock the password.-u- Change a user’s password with the specified username and unlock the password.
# Change a user's password with the username "user" and delete the passwordpasswd -d user
# Change a user's password with the username "user" and expire the passwordpasswd -e user
# Change a user's password with the username "user" and lock the passwordpasswd -l user
# Change a user's password with the username "user" and unlock the passwordpasswd -u usergroupmod
The groupmod command is used to modify a group. It takes a group name as an argument. The output of the groupmod command is the group that was modified.
# Modify a group with the group name "group"groupmod groupgroupmod flags
-g- Modify a group with the specified group ID.-n- Modify a group with the specified group name.
# Modify a group with the group name "group" and group ID "1000"groupmod -g 1000 group
# Modify a group with the group name "group" and group name "group2"groupmod -n group2 groupManaging permissions
Two commands that shape the permissions of what you create: newgrp switches your active group, and umask decides which permission bits new files and directories start without.
newgrp
The newgrp command is used to change the group of the current user. It takes a group name as an argument. The output of the newgrp command is the group that was changed.
# Change the group of the current user with the group name "group"newgrp groupnewgrp flags
-- Start a login shell with the new group, reinitialising the environment as if you had just logged in.-l- Same as-.
# Switch to the group "group" in a fresh login environmentnewgrp - group
# Same as abovenewgrp -l groupumask
The umask command sets the file mode creation mask: the permission bits that are removed from every new file and directory. Run it without an argument to print the current mask.
# New files get 644 and new directories 755 (write removed for group and others)umask 022umask flags
-S- Print the mask in symbolic form, as the permissions new files keep.
# Print the current mask, e.g. u=rwx,g=rx,o=rxumask -SSummary
You learnt about Linux CLI commands in this tutorial, along with the fundamental commands for:
- File management
- Finding files and directories
- Check user information
- Managing users and groups
- Managing permissions
More commands
This post sticks to the basics. For the next layer, use these references:
- Linux Networking cheatsheet:
ip,ss,dig,curl,tcpdump, and the rest of network troubleshooting. - Linux Processes cheatsheet:
ps,top,kill, scheduling and priorities. - Bash cheatsheet: variables, loops, redirection and scripting.
- Linux Server Administration glossary: the terms behind users, permissions, services and system administration.
Note
Revised in November 2026. Earlier versions listed about 50 more commands whose flag descriptions were wrong. They were removed rather than left up, and the cheatsheets above cover those commands correctly.
References
- The Linux Command Line by William Shotts (Free Book)
- Linux Journey - Learning Portal
- Ubuntu Manpages Online (Useful for checking specific command options)
- GNU Coreutils Manual (Covers many basic commands like
ls,cp,mv,rm) - ArchWiki - Command-line shell
- Red Hat Enterprise Linux Documentation
- Debian Administrator’s Handbook
mancommand (Your local Linux system’s manual pages, e.g.,man ls)- DigitalOcean Community Tutorials - Linux Basics
- TecMint - Linux How-To Guides
- Explain Shell - Write a command to see the help text that matches each argument
- Linux Foundation - Training & Certification
- Ryan’s Tutorials - Linux
- SS64 Command line reference - Linux
- Linuxize - Linux Howtos, Tutorials & Guides









