Sheet ⁨02⁩ · ⁨Blog⁩Surveyed ⁨2026⁩

Blog post image for Linux CLI Essentials: Files, Users, Navigation - The Linux commands a beginner uses in the first hour at a shell: moving around the filesystem, working with files, reading them, finding commands, and checking and managing users and groups.

Linux CLI Essentials: Files, Users, Navigation

Published: Updated: 10 Mins read
Markdown for AI(opens in a new tab)

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.

Terminal window
# Print the current working directory
pwd

pwd 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.
Terminal window
# Print the current working directory
pwd -L
# Print the current working directory
pwd -P

ls

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.

Terminal window
# List the contents of the current working directory
ls

ls 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.
Terminal window
# List all files, including hidden files
ls -a
# List files in long format
ls -l
# List files in human-readable format
ls -h
# List files in reverse order
ls -r
# List files by the time they were last modified
ls -t

cd

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.

Terminal window
# Change the current working directory to the home directory
cd ~

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.

Terminal window
# Create a new directory named "new-directory"
mkdir new-directory

mkdir flags

  • -p - Create parent directories as needed.
Terminal window
# Create a new directory named "new-directory" and its parent directories
mkdir -p new-directory

touch

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.

Terminal window
# Create a new file named "new-file"
touch new-file

touch 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.
Terminal window
# Change the access time of the file
touch -a new-file
# Change the modification time of the file
touch -m new-file
# Set both times to 1 January 2026, 12:00
touch -t 202601011200 new-file

cp

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.

Terminal window
# Copy the file "file" to the directory "directory"
cp file directory

cp flags

  • -r - Copy directories recursively.
Terminal window
# Copy the directory "directory" to the directory "new-directory"
cp -r directory new-directory

mv

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.

Terminal window
# Move the file "file" to the directory "directory"
mv file directory

mv 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.
Terminal window
# Move the file "file" to the directory "directory" and prompt before overwriting an existing file
mv -i file directory
# Move the file "file" to the directory "directory" and force the move of a file, even if it already exists
mv -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 file
mv -u file directory

rm

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.

Terminal window
# Remove the file "file"
rm file

rm flags

  • -r - Remove directories and their contents recursively.
  • -f - Force remove files without prompting for confirmation.
Terminal window
# Remove the directory "directory" and its contents recursively
rm -r directory
# Remove the file "file" without prompting for confirmation
rm -f file

rmdir

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.

Terminal window
# Remove the directory "directory"
rmdir directory

rmdir flags

  • -p - Remove parent directories as needed.
Terminal window
# Remove the directory "directory" and its parent directories
rmdir -p directory

cat

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.

Terminal window
# Display the contents of the file "file"
cat file

cat flags

  • -n - Number all output lines.
Terminal window
# Display the contents of the file "file" and number all output lines
cat -n file

more

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.

Terminal window
# Display the contents of the file "file"
more file

more flags

  • -d - Show a “[Press space to continue, ‘q’ to quit.]” prompt instead of ringing the bell on an invalid key.
Terminal window
# Display the contents of the file "file" with a help prompt
more -d file

less

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.

Terminal window
# Display the contents of the file "file"
less file

less flags

  • -N - Display the contents of the file “file” and number all output lines.
Terminal window
# Display the contents of the file "file" and number all output lines
less -N file

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.

Terminal window
# Display the first 10 lines of the file "file"
head file

head flags

  • -n - Display the first n lines of the file “file”.
Terminal window
# Display the first 5 lines of the file "file"
head -n 5 file

tail

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.

Terminal window
# Display the last 10 lines of the file "file"
tail file

tail flags

  • -n - Display the last n lines of the file “file”.
Terminal window
# Display the last 5 lines of the file "file"
tail -n 5 file

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

Terminal window
# Find all files and directories in the current directory with the name "file"
locate file

locate flags

  • -i - Find files and directories with the specified name, ignoring case.
Terminal window
# Find all files and directories in the current directory with the name "file" ignoring case
locate -i file

which

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.

Terminal window
# Find the location of the command "command"
which command

which flags

  • -a - Find all locations of the specified command.
Terminal window
# Find all locations of the command "command"
which -a command

whereis

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.

Terminal window
# Find the location of the command "command"
whereis command

whereis flags

  • -b - Search only for the binary, not the man pages or source files.
Terminal window
# Find only the binary of the command "command"
whereis -b command

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

Terminal window
# Display the current user
whoami

who

The who command is used to display the current users. It takes no arguments. The output of the who command is the current users.

Terminal window
# Display the current users
who

who flags

  • -u - Also show each user’s idle time and login process ID.
Terminal window
# Display the logged-in users with idle time and process ID
who -u

w

The w command is used to display the current users. It takes no arguments. The output of the w command is the current users.

Terminal window
# Display the current users
w

w flags

  • -u - Ignore the username when working out the current process and CPU times.
Terminal window
# Display the logged-in users, ignoring the username for process and CPU times
w -u

id

The id command is used to display the current user. It takes no arguments. The output of the id command is the current user.

Terminal window
# Display the current user
id

id flags

  • -u - Print only the effective user ID.
Terminal window
# Print the numeric user ID of the current user
id -u

groups

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.

Terminal window
# Display the current user's groups
groups

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

Terminal window
# Delete a user with the username "user"
userdel user

userdel flags

  • -r - Also remove the user’s home directory and mail spool.
Terminal window
# Delete the user "user" along with their home directory
userdel -r user

passwd

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.

Terminal window
# Change a user's password with the username "user"
passwd user

passwd 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.
Terminal window
# Change a user's password with the username "user" and delete the password
passwd -d user
# Change a user's password with the username "user" and expire the password
passwd -e user
# Change a user's password with the username "user" and lock the password
passwd -l user
# Change a user's password with the username "user" and unlock the password
passwd -u user

groupmod

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.

Terminal window
# Modify a group with the group name "group"
groupmod group

groupmod flags

  • -g - Modify a group with the specified group ID.
  • -n - Modify a group with the specified group name.
Terminal window
# 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 group

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

Terminal window
# Change the group of the current user with the group name "group"
newgrp group

newgrp flags

  • - - Start a login shell with the new group, reinitialising the environment as if you had just logged in.
  • -l - Same as -.
Terminal window
# Switch to the group "group" in a fresh login environment
newgrp - group
# Same as above
newgrp -l group

umask

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.

Terminal window
# New files get 644 and new directories 755 (write removed for group and others)
umask 022

umask flags

  • -S - Print the mask in symbolic form, as the permissions new files keep.
Terminal window
# Print the current mask, e.g. u=rwx,g=rx,o=rx
umask -S

Summary

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:

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

Was this useful?

You might also enjoy

More posts on similar topics

VIM Cheat Sheet

VIM Cheat Sheet

What is VIM? VIM (Vi Improved) is a versatile text editor pre-installed on most Linux systems, known for its efficiency in command-line file editing. Its modal nature, switching between modes like

How To Install Docker On Linux In 4 Easy Steps

How To Install Docker On Linux In 4 Easy Steps

Introduction Docker is a platform that lets developers create, deploy, and run applications in containers. Containers are isolated environments that allow you to run your applications in a consist

Git SSH Keys for GitHub, GitLab, and Bitbucket on Linux

Git SSH Keys for GitHub, GitLab, and Bitbucket on Linux

Introduction By default, Git talks to remotes over HTTPS, so it asks for your username and password on every git pull or git push. SSH fixes that. GitHub, GitLab, and Bitbucket all let Git aut

Dotfiles: A Git-Based Strategy for Configuration Management

Dotfiles: A Git-Based Strategy for Configuration Management

Introduction Your dotfiles, those hidden .-prefixed configuration files scattered across your home directory, are the muscle memory of your environment. They hold your shell aliases, your editor

How to Install and Setup FireWall on Amazon Linux 2

How to Install and Setup FireWall on Amazon Linux 2

Amazon Linux 2 reached its announced end-of-support date on 30 June 2026, so it is no longer the right base image for a new instance. iptables/firewalld behave the sa

How to Install Apache Web Server on Amazon Linux 2

How to Install Apache Web Server on Amazon Linux 2

Amazon Linux 2 reached its announced end-of-support date on 30 June 2026, so it is no longer the right base image for a new instance. On Amazon Linux 2023 the same steps

6 related posts