Linux commands cheat sheet
Navigation and files
-
pwdShow the full path of the current directory.
-
ls -laList all files in the directory, including hidden ones, with permissions, owner, size, and modification date.
-
ls -lhList files with human-readable sizes, such as K, M, or G.
-
cd /var/www/exampleChange to the given directory. cd .. moves up one level, and cd on its own returns to your home directory.
-
mkdir -p /var/www/example/public/uploadsCreate a directory, including any missing parent directories in the path.
-
touch index.htmlCreate an empty file, or update the timestamp of an existing file.
-
cp config.php config.php.bakCopy a file to a new name, a quick way to back it up before editing.
-
cp -r /var/www/example /var/www/example-backupCopy an entire directory with all its contents.
-
mv old-name.txt new-name.txtRename a file or directory, or move it to another location. Caution: an existing file with the target name is overwritten without warning.
-
rm file.txtCaution: permanently delete a file. There is no recycle bin.
-
rm -r /var/www/example/old-folderCaution: permanently delete a directory with all its contents, so check the path twice before running it. Adding -f skips the confirmation prompts, which makes rm -rf especially risky when the path is wrong or contains an empty variable.
-
find /var/www/example -name "*.log"Find files by name or pattern in a directory and all its subdirectories.
-
find /var/www/example -type f -mtime -1List files modified in the last 24 hours, to spot unexpected changes to the website.
-
du -sh /var/www/example/*Show how much space each file and directory takes up, to find what is filling the disk.
-
df -hShow the total, used, and free space on each mounted partition on the server.
-
ls -ltList the files in the directory, sorted by modification time, newest first.
-
ln -s /var/www/example/releases/new /var/www/example/currentCreate a symbolic link named current that points to the chosen directory. Deleting the link does not delete the directory it points to.
-
stat file.phpShow detailed information about the file, including its size, its permissions in numeric and symbolic form, the owner, and the access and modification times.
Viewing and editing
-
cat config.phpPrint the entire contents of the file to the screen. Best for short files.
-
less /var/log/example.logOpen a file for reading with scrolling and search. Best for long files. Inside less, the / key starts a search and the q key closes the view.
-
head -n 20 file.txtShow the first 20 lines of the file.
-
tail -n 50 /var/log/example.logShow the last 50 lines of the file, usually the most recent part of a log.
-
tail -f /var/log/example.logFollow the file in real time and show each new line written to it. Press Ctrl+C to stop following.
-
nano /var/www/example/.htaccessOpen the file in a simple text editor inside the terminal. Save with Ctrl+O and exit with Ctrl+X.
-
grep -rn "example_text" /var/www/exampleSearch for text in all files in the directory and show the file name and line number of each match.
-
grep -i "error" /var/log/example.logShow the lines in the file that contain the given word, ignoring case.
-
wc -l /var/log/example.logCount the lines in the file.
-
vi notes.txtOpen the file in the vi editor, available on almost every Linux server even when nano is not installed. The i key switches to insert mode and the Esc key leaves it. Type :wq to save and exit, or :q! to exit without saving, and in both cases press Enter to confirm.
-
zgrep "error" /var/log/example.log.2.gzSearch for text inside an old log compressed in gz format, without extracting it. Similarly, zcat shows the full contents of a compressed file.
Permissions and ownership
-
ls -l file.phpShow the permissions, owner, and group of the file. The string -rw-r--r-- stands for 644 permissions: read and write for the owner, and read-only for everyone else.
-
chmod 644 file.phpSet file permissions: read and write for the owner, and read-only for the group and other users, the common setting for website files.
-
chmod 755 /var/www/example/publicSet directory permissions: full access for the owner, and permission to enter and read the directory for the group and other users.
-
chmod +x script.shAdd execute permission to a file, for example a script.
-
find /var/www/example -type d -exec chmod 755 {} \;Apply 755 permissions to all directories in the website, without changing file permissions.
-
find /var/www/example -type f -exec chmod 644 {} \;Apply 644 permissions to all files in the website, without changing directory permissions.
-
sudo chown user:user file.phpChange the owner and group of the file. Changing ownership requires root privileges.
-
sudo chown -R user:user /var/www/exampleChange the ownership of a directory and everything in it.
-
umaskShow the permission mask, which sets the permissions that new files and directories get. The value 0022 creates files with 644 permissions and directories with 755 permissions.
-
chmod 700 ~/.sshRestrict access to the user's SSH directory to the owner only. When the directory or the authorized_keys file is writable by other users, the SSH service may reject key-based logins.
-
chmod 600 ~/.ssh/authorized_keysRestrict access to the authorized keys file so only the owner can read and change it, the recommended setting for this file.
-
find /var/www/example -type f -perm -o=wFind files that any user on the server can modify, a finding that calls for fixing the permissions.
Users and sudo
-
whoamiShow the name of the user you are logged in as.
-
idShow the user ID and all the groups the user belongs to.
-
sudo nano /etc/hostsThe sudo prefix runs a single command with root privileges, usually after you enter the password of the logged-in user. The example opens a system file that a regular user is not allowed to change, so you can edit it.
-
sudo -iOpen a shell as the root user. Leave it with exit as soon as you finish your work.
-
sudo adduser userCreate a new user on the server. On Debian and Ubuntu, the command asks for a password and other details, and on Red Hat-based distributions you set the password separately with passwd.
-
sudo passwd userSet or change the password of the given user. passwd without sudo and without a username changes the password of the logged-in user.
-
sudo usermod -aG sudo userAdd a user to the sudo group and grant root privileges, without removing the user from existing groups. The change takes effect the next time the user logs in. On Red Hat-based distributions, the group is called wheel instead of sudo.
-
su - userSwitch to another user and load that user's full environment.
-
wShow the users currently logged in to the server, with the source address of each connection and the command each user is running.
-
last -n 20Show the last 20 logins to the server, including the username, the source address, and the session length.
Processes and resources
-
topShow the active processes in real time, with the CPU and memory use of each process. Press q to exit and M to sort by memory use.
-
htopShow the same information as top in a colorful, easier-to-use view, with scrolling and process selection (may need to be installed).
-
ps auxList all processes running on the server, including the user, the process ID, and resource use.
-
ps aux | grep phpFilter the process list to show only the lines that contain the given word.
-
kill 1234Ask the process with ID 1234 to shut down cleanly.
-
kill -9 1234Caution: stop the process immediately, with no clean shutdown and no chance to save data, so use it only for a process that does not respond.
-
free -hShow the total, used, and available memory, including swap.
-
uptimeShow how long the server has been running and the load averages for the last 1, 5, and 15 minutes.
-
nprocShow the number of available CPU cores, which helps you read the load averages.
-
pgrep -a phpShow the ID and full command line of every process whose name contains the given text.
-
ps aux --sort=-%mem | head -n 10Show the processes using the most memory, sorted from highest to lowest. Replace %mem with %cpu to sort by CPU use.
Networking
-
ip aShow the server's network interfaces and the IP addresses assigned to them.
-
hostname -IShow the server's IP addresses on a single line.
-
sudo ss -tulpnShow all the ports the server listens on and the process listening on each port.
-
ping -c 4 example.comCheck whether the host responds and measure the response time, stopping after four requests.
-
curl -I https://example.comShow the response headers of a URL, including the status code and the redirect address, if there is one.
-
dig example.com +shortShow the IP address the domain points to, based on its A record (may need to be installed).
-
dig MX example.com +shortShow the domain's MX records, the servers that receive email for it. You can replace MX with another record type, such as TXT, NS, or CNAME.
-
traceroute example.comShow the route traffic takes to the host, to find where delays or drops occur (may need to be installed).
-
curl -s -o /dev/null -w "%{http_code}\n" https://example.comShow only the status code the server returns for the URL, such as 200, 301, or 404. Replace %{http_code} with %{time_total} to show the total load time in seconds.
-
echo | openssl s_client -connect example.com:443 -servername example.com 2>/dev/null | openssl x509 -noout -datesShow the start date and expiration date of the SSL certificate the website actually serves.
Services and logs
-
systemctl status nginxShow whether the service is running, since when, and its latest log lines. You can replace nginx with the name of any other service on the server.
-
sudo systemctl restart nginxStop and start the service again, usually after a configuration change.
-
sudo systemctl reload nginxReload the service's configuration files without stopping it, when the service supports it.
-
sudo systemctl stop nginxStop the service. A service set to start automatically starts again the next time the server boots.
-
sudo systemctl enable --now nginxSet the service to start automatically when the server boots, and start it right away.
-
systemctl list-units --type=service --state=runningList all the services currently running on the server.
-
journalctl -u nginx -fFollow the log of a specific service in real time.
-
journalctl -u nginx --since "1 hour ago"Show the service's log entries from the last hour.
-
journalctl -p err -bShow the errors logged in the system log since the server last booted, including more severe issues.
-
systemctl --failedList the services that failed to start or stopped because of an error.
-
sudo systemctl disable nginxStop the service from starting automatically when the server boots, without stopping the service that is running now.
-
sudo nginx -tCheck the syntax of the nginx configuration files. Run it before reloading the service, so a configuration error does not take the website down. On an Apache server, the equivalent check is apachectl configtest or apache2ctl configtest, depending on the distribution.
Archives and backups
-
tar -czf backup.tar.gz /var/www/exampleCreate a compressed archive of a directory, a common way to back up a website quickly.
-
tar -tzf backup.tar.gzList the files in the archive without extracting it.
-
tar -xzf backup.tar.gzExtract a compressed archive to the current directory. Caution: existing files with the same name are overwritten without warning.
-
tar -xzf backup.tar.gz -C /var/www/restoreExtract an archive to an existing target directory instead of the current directory.
-
zip -r site.zip /var/www/exampleCreate a ZIP file from a directory, a format that also opens directly on Windows and Mac.
-
unzip site.zip -d /var/www/restoreExtract a ZIP file to the target directory.
-
rsync -avz /var/www/example/ user@example.com:/home/user/backup/Sync a directory to another server, transferring only changed files and preserving permissions and timestamps. A trailing slash on the source path copies the contents of the directory, and without the slash the directory itself is copied.
-
rsync -avz --delete --dry-run /var/www/example/ /backup/example/Show which files would be copied and which would be deleted at the destination, without making any changes. Caution: once you remove --dry-run, the --delete option deletes every file at the destination that does not exist at the source.
-
tar -czf backup.tar.gz --exclude="*.log" /var/www/exampleCreate a compressed archive of a directory, skipping the files that match the pattern, in this example the log files.
-
sha256sum backup.tar.gzCalculate the SHA-256 checksum of the file. Comparing the value calculated at the source with the value calculated at the destination confirms that the file was transferred unchanged.
SSH and file transfer
-
ssh user@example.comConnect to a remote server over an encrypted connection.
-
ssh -p 2222 user@example.comConnect to a server whose SSH service listens on a port other than the default port 22.
-
ssh-keygen -t ed25519Create an SSH key pair on your computer: a private key and a public key. You can also create a key in your browser with the "SSH key generator" tool.
-
ssh-copy-id user@example.comCopy your public key to the server, so your next login does not need the server password.
-
scp backup.tar.gz user@example.com:/home/user/Copy a file from your computer to a remote server.
-
scp user@example.com:/home/user/backup.tar.gz .Download a file from the remote server to the current directory on your computer.
-
scp -r /var/www/example user@example.com:/home/user/Copy an entire directory to a remote server.
-
ssh user@example.com "df -h"Run a single command on the remote server, show the output, and disconnect when the command finishes.
-
ssh-keygen -R example.comRemove the server's saved fingerprint from your computer, usually after the server is reinstalled or its address moves to another server. Caution: a fingerprint change warning with no known reason may indicate an interception attempt, so look into it before removing the fingerprint.
Packages and scheduled tasks
-
sudo apt updateRefresh the list of available packages on Debian and Ubuntu, without installing anything.
-
sudo apt upgradeUpgrade all installed packages to the latest versions in the list, so run apt update first.
-
sudo apt install htopInstall a new package on Debian and Ubuntu.
-
sudo apt remove htopRemove an installed package, keeping its configuration files.
-
sudo dnf install htopInstall a package on Red Hat-based distributions, such as Fedora, AlmaLinux, and Rocky Linux.
-
sudo dnf upgradeCheck for updates and upgrade all installed packages on Red Hat-based distributions.
-
crontab -lList the scheduled tasks of the current user.
-
crontab -eOpen the scheduled tasks of the current user for editing. The line 0 3 * * * /home/user/backup.sh runs the script every day at 03:00. To build a schedule, you can use the "Cron expression generator" tool.
-
sudo crontab -u user -lList the scheduled tasks of another user, with root privileges.
-
apt search nginxSearch available packages by name or description on Debian and Ubuntu. On Red Hat-based distributions, you search the same way with dnf search followed by the package name.
-
sudo apt autoremoveOn Debian and Ubuntu, remove packages that were installed as dependencies of other software and are no longer needed. Review the list of packages shown before you confirm.
-
sudo dnf remove htopRemove an installed package on Red Hat-based distributions. Caution: before you confirm, check the list shown to see which dependent packages will be removed with it.
-
crontab -rCaution: delete all the scheduled tasks of the current user without asking for confirmation. The r key is next to the e key on the keyboard, so save a copy of the list with crontab -l > crontab-backup.txt before every edit.
Text processing
-
grep -Ev "^#|^$" /etc/example.confShow the contents of the file without comment lines and blank lines, leaving only the active settings.
-
grep -c " 404 " /var/log/example-access.logCount the lines that contain the given text, not the total number of occurrences.
-
sort -u names.txtSort the lines of the file alphabetically and remove duplicate lines.
-
cut -d: -f1 /etc/passwdShow only the first field of each line, based on the chosen delimiter. In this example, it shows the names of all users on the server, including system users.
-
awk '{print $1}' /var/log/example-access.log | sort | uniq -c | sort -nr | head -n 10Show the ten IP addresses that sent the most requests to the website, based on the access log. awk extracts the first column of each line, and uniq -c counts identical adjacent lines, so the lines must be sorted first.
-
sed 's/old-text/new-text/g' file.txtShow the contents of the file with every occurrence of old-text replaced by new-text, without changing the file itself.
-
sed -i.bak 's/old-text/new-text/g' file.txtCaution: make the replacement in the file itself and keep the original file as file.txt.bak. Run the command without -i first and check the result, because -i without a suffix changes the file with no backup.
-
tr -d '\r' < script.sh > script-fixed.shRemove the CR characters that Windows text editors add at the end of each line and save the result to a new file, to fix a script that fails to run for this reason. Caution: redirecting the output to the source file itself empties it.
-
diff -u config.php.bak config.phpShow the differences between two files, marking added lines with + and removed lines with -.
-
echo "new line" >> file.txtAppend a line to the end of the file, and create the file if it does not exist. Caution: a single > deletes all the existing content of the file and replaces it with the new line.
Disks and partitions
-
lsblkShow the server's disks and partitions as a tree, including the size and mount point of each partition.
-
df -iShow the number of used and free file entries (inodes) on each partition. On a partition that has run out of inodes, you cannot create new files, even when df -h shows free space.
-
du -h --max-depth=1 /var/www/example | sort -hShow the size of each first-level subdirectory, including hidden ones, sorted from smallest to largest.
-
ncdu /var/www/exampleShow how space is used in a directory in an interactive view, moving between subdirectories with the arrow keys (may need to be installed).
-
findmntShow all active mount points as a tree, including the file system type and the mount options.
-
sudo mount /dev/sdb1 /mnt/dataMount a partition on an existing directory. The mount is not kept after the server reboots. Caution: permanent mounts are set in the /etc/fstab file, and an error in this file can prevent the server from booting.
-
sudo umount /mnt/dataUnmount the partition from the directory. Unmounting fails when any process, including a terminal open inside the directory, is using files in it.
System information
-
uname -aShow the kernel version of the operating system, the server name, and the CPU architecture.
-
hostnamectlShow the server name, the operating system, the kernel, and the virtualization type. To change the server name, run sudo hostnamectl set-hostname followed by the new name.
-
cat /etc/os-releaseShow the name and version of the distribution, which you need to choose the right commands for installing and updating.
-
lscpuShow the CPU details, including the model, the number of cores, and the architecture.
-
last rebootShow when the server was booted over time, to check whether an unexpected reboot occurred.
-
sudo dmesg -T | tail -n 50Show the latest kernel messages with readable dates and times, to find disk errors, hardware errors, or processes stopped because the server ran out of memory.
Background jobs and long-running tasks
-
./backup.sh &Run the script in the background and return to the command prompt immediately. The script may stop when the terminal disconnects, so run long jobs with nohup, screen, or tmux, which are described later in this section.
-
jobsList the jobs running in the background or paused in the current terminal, each with a job number.
-
fg %1Bring job number 1 back to the foreground, so you can stop it with Ctrl+C and see its output in the terminal.
-
bg %1Resume a paused job in the background. Pressing Ctrl+Z pauses the command running in the foreground, and bg then resumes it in the background.
-
nohup ./backup.sh > backup.log 2>&1 &Run the script in the background so it keeps running after you disconnect from the server, and write its output and error messages to the backup.log file in the current directory.
-
screen -S workOpen a virtual terminal named work that keeps running after you disconnect from the server (may need to be installed). To detach from the terminal without closing it, press Ctrl+A and then D, and screen -r work takes you back to it.
-
tmux new -s workOpen a virtual terminal named work that keeps running after you disconnect from the server (may need to be installed). To detach from the terminal without closing it, press Ctrl+B and then D, and tmux attach -t work takes you back to it.
Firewall
-
sudo ufw status verboseShow whether the ufw firewall, common on Debian and Ubuntu, is active, and the rules set in it (may need to be installed).
-
sudo ufw allow 22/tcpAllow incoming connections on port 22, the default port of the SSH service. Add this rule before you enable the firewall, and on a server where the SSH service listens on another port, specify the correct port.
-
sudo ufw allow 443/tcpAllow incoming connections on port 443, the port for secure browsing over HTTPS. You can open port 80 for unencrypted browsing the same way.
-
sudo ufw enableCaution: enable the firewall now and every time the server boots. By default, it blocks every incoming connection that a rule does not explicitly allow. Enabling it without a rule that allows SSH may drop your current connection and prevent you from logging in to the server again.
-
sudo ufw delete allow 8080/tcpDelete the rule that allows connections on port 8080. The change takes effect immediately.
-
sudo firewall-cmd --list-allShow the default zone settings of the firewalld firewall, common on Red Hat-based distributions, including the open services and ports.
-
sudo firewall-cmd --permanent --add-service=httpsPermanently open the HTTPS service (port 443) in the firewall. The change takes effect only after the firewall is reloaded.
-
sudo firewall-cmd --permanent --add-port=8080/tcpPermanently open port 8080 for TCP connections. The change takes effect only after the firewall is reloaded.
-
sudo firewall-cmd --permanent --remove-port=8080/tcpPermanently close port 8080, which was opened earlier. Caution: removing the SSH port or the SSH service may block access to the server after the reload.
-
sudo firewall-cmd --reloadReload the permanent firewall settings and apply them. Changes made without --permanent are lost on reload.
Environment variables and aliases
-
echo $PATHShow the list of directories where the shell looks for the commands you type, separated by colons.
-
export APP_ENV=productionSet an environment variable that is available to every command you run from the current terminal. The setting is lost when you close the terminal, and to make it permanent, add the line to the user's ~/.bashrc file.
-
envList all environment variables set in the current terminal.
-
alias ll='ls -la'Create an alias named ll, so typing it runs the full ls -la command. The alias is lost when you close the terminal, and to keep it permanently, add the line to the user's ~/.bashrc file.
-
source ~/.bashrcReload the shell settings file, so the changes in it apply immediately in the current terminal without logging in again.
-
which phpShow the full path of the command that will actually run, useful when several versions of the same software are installed.
-
type llShow whether the name is an alias, a shell builtin, or an executable file, along with the contents of the alias or the path of the file.
-
history | grep rsyncSearch the user's command history for the lines that contain the given word, to find a long command you have already run. Typing an exclamation mark followed by the line number from the history runs that command again.
-
sudo !!Run the last command again with root privileges, usually after it failed because of missing permissions. Caution: the command runs immediately, so check what the last command was before you use it.
Date and time
-
dateShow the current date and time in the server's time zone.
-
date "+%Y-%m-%d %H:%M:%S"Show the date and time in the chosen format. The expression $(date +%F) in a file name, such as backup-$(date +%F).tar.gz, adds the current date to the name, and in a cron job, add \ before every % character, or the line is cut off.
-
date -d @1700000000Convert a Unix timestamp, the number of seconds since January 1, 1970, to a readable date and time.
-
timedatectlShow the local time, the UTC time, the server's time zone, and whether the clock is synchronized automatically.
-
timedatectl list-timezones | grep EuropeShow the names of the available time zones and filter them by continent, in this example Europe.
-
sudo timedatectl set-timezone UTCCaution: change the server's time zone, so scheduled tasks and the times shown in logs are based on the new time zone from now on. If cron jobs keep running on the previous time zone, restart the cron service.
Downloading files
-
wget https://example.com/file.zipDownload a file to the current directory and save it under its original name (may need to be installed).
-
wget -c https://example.com/file.zipResume an interrupted download from where it stopped, without downloading the existing part again.
-
curl -O https://example.com/file.zipDownload a file and save it under the name at the end of the URL. Without the -O option, the content is printed to the screen instead of being saved.
-
curl -L -o file.zip https://example.com/downloadDownload a file, follow redirects to the final URL, and save the content under the chosen name.
-
curl -fsSL -o install.sh https://example.com/install.shDownload an installation script to a local file, and fail with an error message when the server returns an error code. Caution: read the script before running it, instead of passing the download straight to a shell.
Advanced search
-
find /var/www/example -type f -mmin -60List files modified in the last 60 minutes, for a quick check after an update or a suspected break-in.
-
sudo find / -xdev -type f -size +500MFind files larger than 500 MB on the root partition only, without scanning other partitions mounted under it.
-
find /var/www/example/tmp -type f -mtime +7 -deleteCaution: permanently delete files that have not been modified for more than seven days. Run the command without -delete first and check the list of files, and place -delete only at the end of the command, because placing it earlier also deletes files that do not match the conditions.
-
find /var/www/example -name "*.php" -print0 | xargs -0 grep -l "base64_decode"Search for text in all PHP files in the directory and show only the names of the files with a match. Combining -print0 with xargs -0 also handles file names that contain spaces correctly.
-
locate config.phpQuickly find files by name from a database that is usually updated once a day, so new files do not appear in the results until the database is updated (may need to be installed). The sudo updatedb command updates the database manually.
No matching commands.
You run Linux commands in a terminal. Mac and Linux computers come with a terminal preinstalled, and on recent Windows computers you can use PowerShell or Windows Terminal, where the ssh command is available without installing anything.
Logging in with an SSH key instead of a password is more secure and more convenient. You can create a key pair with the SSH key generator, copy the public key to the server, and log in without typing a password. To build file permissions, you can use the chmod calculator, and to build a schedule for a task, the Cron expression generator.
A word of caution about chmod 777: this permission lets every user and every process on the server read, change, and run the file, so it makes it possible to plant malicious code. When a website cannot write to a directory, the right fix is to correct the ownership with chown, not to open the permissions to everyone. To calculate a numeric value from symbolic permissions, you can use the chmod calculator.
A few habits save a lot of time in the terminal. The Tab key completes the names of commands, files, and directories. The up and down arrow keys move through your previous commands, and the history command shows all of them. For full details on any command, run man followed by the command name, or add --help to the command itself.
Working safely with a firewall
A server's firewall is usually managed with a single tool: ufw is common on Debian and Ubuntu, and firewalld is common on Red Hat-based distributions. On a server where the firewall is managed with another tool, manage the rules only through that tool, without running a second tool alongside it. Before you change any rules, open a second SSH connection and leave it open, and after the change, check that you can log in again, so a mistaken rule does not lock you out of the server.
A Linux VPS comes with full root access over SSH, so you can run commands on the server's command line.
Linux commands FAQ
How do I connect to a Linux server?
You connect to a Linux server from the terminal with the command ssh user@example.com, where user is your username on the server and example.com is the domain or IP address of the server. On your first connection, the terminal asks you to confirm the server's fingerprint, and then you log in with a password or an SSH key.
What is the difference between apt and dnf?
The difference between apt and dnf is the distribution family each command is used on. The apt command is used on Debian and Ubuntu, and the dnf command is used on Red Hat-based distributions, such as Fedora, AlmaLinux, and Rocky Linux. Both commands install, upgrade, and remove software.
How do I find out what is taking up disk space?
You find the largest directories with the du -sh command, which shows the size of each directory in the given path. Keep moving into the directory that takes up the most space, and use the df -h command to see how much free space is left on each partition.
What do the numbers 644 and 755 mean in permissions?
The numbers 644 and 755 describe the permissions of the owner, the group, and other users, one digit for each, in that order. Each digit is the sum of read (4), write (2), and execute (1). The value 644 suits most website files, and the value 755 suits directories and scripts that need to run.
How do I exit nano, less, or a command that does not stop?
To exit nano, press Ctrl+X, and to exit less or top, press q. A command that keeps running, such as tail -f, stops when you press Ctrl+C.