Linux systems are commonly managed through a command-line shell, whether you are sitting at the computer itself or connecting from another machine over the network. Learning how to log in, recognize the prompt, and type basic commands gives you direct control over files, programs, and system information.
The first commands worth learning are practical ones: moving between directories, listing files, reading file contents, copying or renaming items, checking permissions, viewing running processes, and finding built-in help. These skills form the foundation for everyday Linux use and make later administration tasks much easier to understand.
As an Amazon Associate I earn from qualifying purchases.
Because the command line can make changes immediately, safe habits matter from the start. Reading commands before running them, avoiding destructive options until you understand them, and practicing in noncritical directories can help you build confidence while reducing the risk of accidental data loss.
The Tool Desk
Outbyte PC Repair FREEClear out junk files and repair common Windows errorsFree Scan →Outbyte Driver Updater FREEScan for outdated or missing drivers - takes under a minuteDriver Scan →Logging In to a Linux System
Before you can run Linux commands, you need access to a Linux session. This can happen directly at the machine, through a graphical desktop, through a text console, or remotely over the network. In all cases, you usually authenticate with a username and a password, though remote systems may also use SSH keys. Usernames are case-sensitive on Linux, so alex and Alex are treated as different accounts.
#1 Best Overall
Logging in locally
If you are sitting in front of the computer, you may see a graphical login screen. Select or type your username, enter your password, and the desktop environment will open. From there, you can start a terminal application, often named Terminal, Konsole, GNOME Terminal, or XTerm. The terminal gives you access to the shell, where commands are typed.
On servers or minimal installations, you may see a text login prompt instead of a desktop. It may look like this:
localhost login:
Type your username, press Enter, then type your password. The password will usually not appear on the screen as you type; this is normal and helps prevent others from seeing its length. After a successful login, Linux starts a shell session and displays a command prompt. If the password is wrong, you will be asked to try again.
Do these 3 things before closing this tab:
1Repair Windows errors before they cause bigger problems2Scan for outdated or missing drivers - takes under a minute3Clear out junk files and repair common Windows errorsLogging in remotely with SSH
The most common way to access a Linux system remotely is with SSH, which creates an encrypted terminal session over the network. From another Linux or macOS system, or from Windows Terminal with OpenSSH installed, use:
ssh username@server-address
For example, if your username is sam and the server address is 192.168.1.50, you would run:
The first time you connect to a server, SSH may ask whether you trust the host fingerprint. Confirm only if you recognize the server address or it was provided by an administrator. After that, enter your password if prompted. Some systems use SSH keys instead of passwords; in that case, your private key on your computer proves your identity to the server.
Switching users and ending a session
After logging in, you normally work as a regular user. Avoid logging in directly as root unless you are specifically administering the system and understand the effect of each command. For administrative tasks, many Linux systems use sudo, which lets an authorized user run a single command with elevated privileges. For example, sudo apt update runs a package update command with administrator rights on Debian-based systems.
Free tools Windows power users keep installed
One-click scans. No signup required.
- whoami shows the username for the current session.
- hostname shows the name of the system you are connected to.
- exit closes the current shell or SSH session.
- logout can also end a login shell session.
When working remotely, always check that you are connected to the intended machine before making changes. Running whoami, hostname, and pwd at the start of a session helps you confirm your user, system, and current directory. When you are finished, type exit to close the session cleanly rather than simply closing the terminal window.
Understanding the Shell Prompt and Command Syntax
After you log in, Linux usually places you at a shell prompt. The shell is the command-line program that reads what you type, runs commands, and prints results. A typical prompt might look like user@server:~$. Although prompts can be customized, they often show your username, the computer’s hostname, your current directory, and a final symbol. The ~ character means your home directory, such as /home/alex. A $ usually means you are working as a regular user, while # usually means you are working as the root user or in an administrator shell.
It is safest to use a regular user account for daily work. Commands run as root can change or delete system files, affect other users, and break services if used carelessly. When a command needs administrator privileges, many Linux systems use sudo, as in sudo systemctl status ssh. When you use sudo, read the command carefully before pressing Enter, especially if it modifies files, installs software, changes permissions, or removes data.
Basic command structure
Most Linux commands follow a simple pattern: command options arguments. The command is the program you want to run, options adjust how it behaves, and arguments tell it what to work on. For example, ls -l /var/log runs ls, uses the -l option for long format, and targets the /var/log directory. Short options often begin with one dash, such as -a, while long options often begin with two dashes, such as –all.
- pwd prints your current working directory.
- ls lists files and directories.
- ls -la lists all entries, including hidden files, in long format.
- cd /etc changes to the /etc directory.
- man ls opens the manual page for the ls command.
Commands and filenames are case-sensitive. Documents, documents, and DOCUMENTS are three different names. Spaces also matter. If a filename contains spaces, put it in quotes, such as cat “meeting s.txt”, or escape each space with a backslash, such as cat meeting\ notes.txt. To avoid mistakes, many users prefer lowercase filenames with hyphens or underscores, like project-notes.txt.
Running commands safely
Before running a command that changes or removes something, confirm where you are with pwd and inspect the target with ls. Be especially careful with wildcards such as *, which can match many files at once. For example, rm *.log removes every file ending in .log in the current directory. A safer habit is to first run ls *.log to see what will be matched, then run the removal command only if the list is correct.
The shell also provides conveniences that reduce typing errors. Press Tab to autocomplete command names, filenames, and directories. Use the Up Arrow to recall previous commands, then edit them instead of retyping from scratch. If a command produces too much output, you can often scroll in your terminal or send the output to a pager, such as ls -la /etc | less. To stop a command that is still running in the foreground, press Ctrl+C. Understanding these prompt details and command patterns makes the rest of the Linux command line much easier to learn.
Navigating the Filesystem
Linux organizes files in a single directory tree that starts at the root directory, written as /. Unlike some desktop systems that show separate drive letters, Linux mounts disks, USB devices, and network storage somewhere under this one tree. When you log in, you usually start in your home directory, such as /home/alex. This is your personal workspace for documents, scripts, downloads, and configuration files.
To see where you are, run pwd, which prints the current working directory. To list what is inside that directory, use ls. A plain ls gives a simple listing, while ls -l shows details such as file size, owner, permissions, and modification time. Use ls -a to include hidden files, whose names begin with a dot, such as .bashrc. A common combined form is ls -la.
Moving between directories
The cd command changes your current directory. You can move using absolute paths, which start at /, or relative paths, which start from your current location. For example, cd /var/log takes you directly to the system log directory, while cd Documents enters a Documents directory inside your current location. To go up one level, use cd ... To return to your home directory, run cd with no arguments or use cd ~.
- pwd — show your current directory.
- ls — list files and directories.
- ls -l — list with detailed information.
- ls -a — include hidden files.
- cd /path/to/directory — move to a directory by path.
- cd .. — move to the parent directory.
- cd – — switch back to the previous directory.
Paths are central to working safely at the command line. An absolute path like /etc/ssh/sshd_config points to one exact location no matter where you are. A relative path like ../reports depends on your current directory. Before running commands that change or remove files, confirm your location with pwd and preview targets with ls. This habit helps prevent mistakes such as editing the wrong file or deleting content from the wrong folder.
Common directories you will encounter
| Directory | Typical use |
|---|---|
| /home | Home directories for regular users. |
| /etc | System-wide configuration files. |
| /var | Variable data such as logs, caches, and mail queues. |
| /tmp | Temporary files, often cleared automatically. |
| /usr | Installed programs, libraries, and shared resources. |
Many filenames and directory names are case-sensitive in Linux, so Reports, reports, and REPORTS can be three different items. If a path contains spaces, wrap it in quotes, such as cd “Project Files”, or escape the space with a backslash, such as cd Project\ Files. You can also press the Tab key to autocomplete filenames and reduce typing errors. If mulle matches exist, pressing Tab again may show the available choices.
PC Slower Than It Used to Be?
A free scan shows the junk files, broken settings and background clutter dragging Windows down - then fixes them in one click.Free scan · Windows 10 & 11Outdated Drivers Are Slowing You Down
One free scan finds every outdated or missing driver and matches the right update for your exact hardware.Free scan · exact hardware matchCreating, Viewing, Copying, Moving, and Deleting Files
Once you can move around the filesystem with commands like pwd, ls, and cd, the next step is working with files and directories. Linux commands often act immediately, so it is best to practice in a safe location such as your home directory. You can create a practice folder with mkdir linux-practice, enter it with cd linux-practice, and test commands there without risking system files.
Creating files and directories
To create an empty file, use touch. For example, touch s.txt creates a file named notes.txt if it does not already exist. To create a directory, use mkdir, such as mkdir projects. You can create nested directories with mkdir -p work/reports/2026, where the -p option creates any missing parent directories along the path.
- touch file.txt creates an empty file or updates its timestamp.
- mkdir foldername creates a new directory.
- mkdir -p parent/child creates nested directories safely.
Viewing file contents
Linux provides several ways to inspect text files. Use cat s.txt to print a short file to the terminal. For longer files, less notes.txt is more comfortable because you can scroll with the arrow keys, search with /word, and quit by pressing q. To preview only part of a file, use head notes.txt for the first lines or tail notes.txt for the last lines. A common command for watching log files is tail -f filename, which keeps displaying new lines as they are added.
| Command | Use | Example |
|---|---|---|
| cat | Show a whole file | cat notes.txt |
| less | Page through a file | less notes.txt |
| head | Show the beginning | head -n 5 notes.txt |
| tail | Show the end | tail -n 20 notes.txt |
Copying and moving files
Use cp to copy files and mv to move or rename them. For example, cp s.txt notes-backup.txt creates a second copy of the file. To copy a file into a directory, run cp notes.txt projects/. To copy a directory and everything inside it, use cp -r projects projects-backup. The -r option means recursive, which tells Linux to include subdirectories and their contents.
Recommended Free Tools
The mv command is used both for moving files and renaming them. For example, mv s.txt old-notes.txt renames the file, while mv old-notes.txt projects/ moves it into the projects directory. Be careful when copying or moving files onto an existing filename, because the destination may be overwritten. For safer use, add -i, as in cp -i file.txt backup.txt or mv -i report.txt reports/, so the shell asks before replacing something.
Deleting files and directories safely
Deletion in the shell is powerful and usually permanent. Use rm filename to remove a file and rmdir empty-folder to remove an empty directory. If a directory contains files, rmdir will refuse to delete it. The command rm -r foldername removes a directory and everything inside it, so check your current location with pwd and review targets with ls before running it. A safer pattern is rm -i filename, which asks for confirmation, or rm -ri foldername, which confirms items during recursive deletion.
- Use ls before deleting to confirm filenames.
- Avoid running rm -r on broad paths unless you are certain.
- Prefer rm -i while learning or when working with valuable files.
- Use quotes for names with spaces, such as rm “old notes.txt”.
Checking File Permissions and Ownership
Linux uses permissions to control who can read, change, or run files and directories. This is one of the main safety features of the system: a regular user should not be able to accidentally modify system files, and one user’s private files should not be readable by everyone. To inspect permissions, use ls -l for a detailed listing. For example, running ls -l s.txt might show output like -rw-r--r-- 1 alex alex 1200 May 25 10:15 notes.txt.
The first part of the listing describes the file type and permissions. The first character is usually - for a regular file or d for a directory. The next nine characters are grouped into three sets: permissions for the owner, the group, and everyone else. Each set can include r for read, w for write, and x for execute. In -rw-r--r--, the owner can read and write, the group can read, and others can read. For a directory, x means you can enter or pass through it, so directories often need execute permission to be usable.
Rank #4
Reading ownership information
In a long listing, the owner and group usually appear after the link count. In -rw-r--r-- 1 alex developers 1200 May 25 10:15 s.txt, the file is owned by user alex and belongs to the developers group. You can also check ownership with stat notes.txt, which displays more detailed information, including access, modification, and change times. If you cannot open, edit, or delete a file, checking its permissions and ownership is often the first practical step.
Changing permissions safely
The chmod command changes permissions. A beginner-friendly form is symbolic mode, such as chmod u+x script.sh, which adds execute permission for the file owner. You can remove permission with a minus sign, for example chmod g-w report.txt removes write permission from the group. You can also assign exact permissions with numeric mode: chmod 644 s.txt gives the owner read and write access, while group and others get read-only access. For scripts that should be executable by the owner only, chmod 700 backup.sh is a common choice.
ls -lshows permissions, owner, group, size, date, and name.chmod u+x fileadds execute permission for the owner.chmod 600 filemakes a file readable and writable only by its owner.chmod 755 directoryis common for directories that others may enter and read.
The chown command changes ownership, and it usually requires administrative privileges. For example, sudo chown alex s.txt changes the owner to alex, while sudo chown alex:developers notes.txt changes both owner and group. Use sudo carefully, especially with recursive options such as -R. A command like sudo chown -R alex:alex /some/path changes ownership for everything under that path, so always confirm the directory with pwd and inspect it with ls before running broad changes.
Viewing Processes and System Information
Linux runs many programs at the same time, including the commands you start, background services, login sessions, and system tasks. These running programs are called processes. Learning how to view them helps you understand what the system is doing, identify heavy resource use, and safely stop programs that are not responding.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
Listing running processes
The ps command shows process information. On its own, it displays processes connected to your current terminal session. A common beginner-friendly form is ps aux, which lists processes from all users with details such as the owner, process ID, CPU use, memory use, start time, and command name. The process ID, usually shown as PID, is the number Linux uses to identify a running process.
| Command | What it does |
|---|---|
ps |
Shows processes running in the current shell session. |
ps aux |
Shows a detailed list of processes for all users. |
top |
Displays a live, updating view of processes and system load. |
htop |
Shows an interactive process viewer, if installed. |
For a real-time view, run top. It updates continuously and shows CPU usage, memory usage, uptime, load average, and the busiest processes. Press q to quit. Many systems also offer htop, which is easier to read and navigate with the keyboard, but it may need to be installed first. If you are connected to a shared or production server, avoid stopping unfamiliar processes unless you know what they are for.
Stopping a process safely
If a program is stuck, first try to close it normally. In a terminal, you can often press Ctrl+C to interrupt the current foreground command. If that does not work, find the process ID with ps aux or top, then send a normal termination request with kill PID, replacing PID with the actual number. For example, kill 2481 asks process 2481 to exit cleanly. Use stronger signals only as a last resort, because they can stop a program without letting it save data.
Checking system details
Linux includes several commands for viewing basic system information. Use uname -a to display kernel and architecture details. Use hostname to show the system name, and whoami to confirm the user account you are currently using. To see how long the system has been running and how busy it is, run uptime. The load average values shown by uptime and top describe recent demand on the CPU; lower values generally mean the system is less busy.
free -hshows memory usage in human-readable units such as MiB and GiB.df -hshows disk space usage for mounted filesystems.du -sh directory_nameshows the total size of a specific directory.dateprints the current system date and time.whoshows users currently logged in.
When checking disk usage, be careful with commands that scan large directories, such as du on /, because they can take time and produce a lot of output. Start with targeted paths, such as du -sh Downloads or du -sh /var/log if you have permission. These commands are read-only, making them safe for beginners when used to observe the system rather than modify it.
Best Value
Getting Help and Using Command History
Linux includes built-in help tools that are available directly from the terminal. When you are unsure how a command works, start with the manual page by typing man command, such as man ls or man chmod. Manual pages usually describe what the command does, show its syntax, list available options, and sometimes provide examples. You can scroll with the arrow keys, press Space to move down a page, search with /word, and quit with q.
Many commands also support quick help options. Try command –help, such as cp –help, for a shorter reference. Some commands use -h instead, although this is not universal. For shell built-ins like cd, alias, or history, use help cd or help history in Bash. If you know what you want to do but not the exact command, apropos keyword can search manual page descriptions; for example, apropos password lists commands related to passwords.
Useful help and discovery commands
- man pwd opens the full manual page for pwd.
- ls –help shows common options for listing files.
- whatis tar gives a brief description of the tar command.
- apropos network searches for commands related to networking.
- type cd shows whether a command is built into the shell or found as a program.
- which ssh shows the path to the executable that will run.
Command history saves time and helps you repeat or adjust previous work. Press the Up Arrow to bring back earlier commands and the Down Arrow to move forward again. Type history to view a numbered list of recent commands. To re-run a command from that list, you can use !number, such as !42, but be careful: it runs immediately. A safer beginner habit is to use the arrow keys, edit the command if needed, and press Enter only after reviewing it.
Quick wins for a faster PC:
Fix the driver behind crashes, sound loss and screen glitchesFind Drivers →Clear out junk files and repair common Windows errorsFree Scan →Scan for outdated or missing drivers - takes under a minuteDriver Scan →You can search command history interactively with Ctrl+r. Start typing part of a previous command, such as ssh or grep, and the shell will show a matching entry. Press Ctrl+r again to cycle through older matches, Enter to run the displayed command, or the arrow keys to edit it first. If you decide not to use it, press Ctrl+c. This is especially useful for long commands with paths, options, or remote hostnames.
Use history carefully on shared systems. Commands may include filenames, server names, or sensitive arguments. Avoid typing passwords directly into commands because they can be stored in history and may also appear in process listings. Prefer prompts, configuration files with correct permissions, or secure tools designed for secrets. Before reusing destructive commands such as rm, mv, chmod, or commands run with sudo, reread the full line, confirm the path with pwd or ls, and make sure wildcards such as * match only what you intend.
Frequently Asked Questions
What is the difference between logging in locally and logging in with SSH?
Logging in locally means you are using the computer directly with its keyboard, mouse, and screen, or through a local virtual machine console. Logging in with SSH connects to a Linux system over a network using a command such as ssh user@server. SSH is common for managing servers because it gives you a secure terminal session without needing physical access.
How do I know which directory I am currently in?
Run pwd to print your current working directory. You can list the files there with ls, or use ls -la to include hidden files and detailed information. The shell prompt may also show part of your current path, but pwd is the most reliable way to confirm it.
What should I do before deleting files with rm?
Use ls to confirm the exact file names and location before running rm. Be especially careful with wildcards like * and recursive deletion such as rm -r, because deleted files usually do not go to a trash folder in the terminal. If you are unsure, move files to a temporary folder first with mv instead of deleting them immediately.
How can I check whether I have permission to edit or run a file?
Run ls -l filename to view the file’s permissions, owner, and group. The permission string shows read, write, and execute access for the owner, group, and everyone else. For example, execute permission is needed to run a script directly, while write permission is needed to modify or delete a file in many cases.
How do I find help for a command I do not understand?
Start with command --help for a quick usage , such as ls --help. For more complete documentation, use man command, such as man chmod, and press q to quit the manual page. You can also press the up arrow to reuse previous commands and edit them instead of typing from scratch.
Bottom Line
Logging in to Linux, recognizing the shell prompt, and practicing basic commands gives you the foundation to work confidently from the terminal. Start with safe, everyday tasks like checking your location with pwd, listing files with ls, moving around with cd, reading files with cat or less, and using man or --help whenever you are unsure.
As you build experience, be careful with commands that change or delete files, especially when using sudo, wildcards, or recursive options. Keep practicing in a test directory, review each command before pressing Enter, and you’ll quickly develop the habits needed to manage a Linux system safely and effectively.
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.




