Skip to content

The Basic Linux Manual

A basic summary of useful Linux commands for beginners.

Original concept from "The One Page Linux Manual" by squadron (May 1999 version 3.0).

Note

Some commands listed may require elevated permission to run.

Note

For more advanced examples see Linux Quick Reference Commands.

Starting And Stopping

Command Example Info
systemctl poweroff Stop all processes, unmount file systems and then poweroff the system now and do not reboot.
systemctl halt Stop all processes, unmount file systems and then shutdown the system and halt. Do not reboot/poweroff.
systemctl reboot Stop all processes and then reboot the system.
startx Start the X Window system (GUI).

Accessing And Mounting File Systems

Devices starting with "hd" (MFM/IDE hard disk devices) and "sd" (driver for SCSI disk drives).

Command Example Info
mount List mounted file systems.
mount -a Mount all filesystems within the /etc/fstab with exception to those who contain the noauto keyword. The filesystems are mounted following their order in the fstab.
mount -t iso9660 /dev/cdrom /mnt/cdrom Mount the device cdrom and call it cdrom under the /mnt directory.
mount -t msdos /dev/hdd /mnt/ddrive Mount hard drive d as a MS-DOS file system and call it ddrive under /mnt directory.
mount -t vfat /dev/hda1 /mnt/cddrive Mount hard disk as a VFAT file system and call it cddrive under the /mnt directory.
mount /dev/sdb1 /mnt/sdb1 Mount SCSI disk drive b partition 1 using auto file system type and call it sdb1 under the /mnt directory. If no -t option is given mount will attempt to guess the desired file system type.
umount /mnt/cdrom Unmount the file system cdrom.

Finding Files and Text Within Files

Command Example Info
find / -name fname Starting with the root directory, look for the file called "fname".
find / -name "*fname*" Starting with the root directory, look for the file containing the string "fname".
locate missingFilename Find the file called "MissingFilename" within one or more databases. See command below.
updatedb Create or update the database of files on all file systems attached to the Linux root directory.
which missingFilename Show the sub-directory containing the executable file called "missingFilename".
grep textstringtofind /dir Starting with the directory called "dir", look for and list all files containing "textstringtofind".

The X Window System

Command Example Info
xvidtune Run the X graphics tuning utility.
XF86setup Run the X configuration menu with automatic probing of graphics cards.
Xconfigurator Run another X configuration menu with automatic probing of graphics cards.
x86config Run a test based X configuration menu.

Moving, Copying, Deleting & Viewing Files

Command Example Info
cd dirname Change directory to "dirname".
cd .. Change directory back one level from current position.
cd ../.. Change directory back two levels from current position.
cd ~ Change directory to the user's home directory.
cat filetoview Display the file called "filetoview".
cp filename /home/dirname Copy the file called "filename" to the "/home/dirname" directory.
cp -p filename /home/dirname Copy the file called "filename" to the "/home/dirname" directory and preserve ownership/permissions.
head filetoview Display the first 10 lines of the file called "filetoview".
ls List files in current directory.
ls -al List all files in current directory using long format.
ll Alias for "ls -al". Set on all Linux systems at DSI.
ls -alt List all files in current directory using the long format and sort by modification time, newest first.
mv filename /home/dirname Move the file called "filename" to the "/home/dirname" directory.
more filetoview Display the file called "filetoview" one page at a time, proceed to next page using the spacebar.
nano filetoview Display the file called "filetoview" and edit if desired.
nano +50 filetoview Display the file called "filetoview" and edit if desired jumping to line number 50.
pwd Display the current working directory.
rm name Remove a file or directory called "name".
rm -r name Remove an entire directory including files and sub-directories without prompting.
stat filename Display the file status/details for the file "filename".
tail filetoview Display the last 10 lines of the file called "filetoview".
tail -20 filetoview Display the last 20 lines of the file called "filetoview".
vi filetoview Display the file called "filetoview" and edit if desired.

Installing Software

Command Example Info
aptitude Iterative package manager shell application.
aptitude install package Install the package called "package".
aptitude remove package Remote the package called "package" and leave the configuration files.
aptitude purge package Remove the package called "package and remove associated configuration files.
apt-get install package Install the package called "package".
apt-get remove package Remove the package called "package" and leave the configuration files.
apt-get purge package Remove the package called "package and remove associated configuration files.
make Build/compile the program after ./configure.
gunzip archive.gz Decompress the files contained within the zipped archive called "archive" to current directory.
tar -xvf archive.tar Extract files contained within the tarred archive called "archive".
tar -xvf archive.tar.bz2 Decompress files contained within the bzip2 and tarred archive called "archive".
tar -zxvf archive.tar.gz Decompress the files contained within the zipped and tar archive called "archive" to current directory.
tar -zxvf archive.tgz Decompress the files contained within the zipped and tar archive called "archive" to current directory.
tar -xvJf archive.tar.xz Decompress files contained within the xz and tar archive called "archive".
tar -I zstd -xvf archive.tar.zst Decompress files contained within the zstd and tar archive called "archive".
./configure Execute the script preparing the installed files for compiling.

User Administration

Command Example Info
add username Create a new user with the username of "username".
addgroup groupname Create a user group called "groupname".
deluser username Delete user with the username of "username".
delgroup groupname Delete the user group called "groupname".
exit Stop being superuser and revert to normal user or quit/exit session.
loginctl list-users List currently logged in users.
loginctl list-sessions List current sessions.
loginctl show-session 38 Display properties of one or more session(s) for "38".
loginctl terminate-session 38 Terminate the session "38". This kills all processes of a session and frees all resources attached to the session.
loginctl user-status username Display status of the user "username".
groups List user available groups.
groups username List the groups the user "username" is apart of.
gpasswd -a username groupname Add the user with "username" to the group "groupname".
last Display listings of last logged in users.
passwd username Set the user of "username" with a new password.
sudo su Login as superuser from current login.
su Login as superuser from current login.
sudo -u username Run command as a specific user (e.g. username).
usermod -a -G groupname username Add the user with "username" to the group "groupname".
users List the usernames of users currently logged in.
who List who is logged in currently with username, tty, datetime of login and user's remote IP address.
w Display who is logged in and what they are doing.

Networking

Command Example Info
dhclient eth0 Refresh DHCP for NIC called "eth0".
ifconfig -a Display all network interface cards (NICs) information.
ifconfig eth0 192.168.1.102 netmask 255.255.255.0 broadcast 192.168.1.255 Setup/Configure NIC called "eth0" for current session. Will be lost a system reboot.
ifconfig eth0:1 192.168.0.235 netmask 255.255.255.0 up Add a second IP address (multiple) to NIC called "eth0" and bring online for current session. Will be lost a system reboot.
ifconfig eth0:2 192.168.0.236 netmask 255.255.255.0 up Add a third IP address (multiple) to NIC called "eth0" and bring online for current session. Will be lost a system reboot.
ifconfig eth0 down Turn off/disable NIC called "eth0".
ifconfig eht0 up Turn On/Enable NIC called "eth0".
ip link set eth0 up Turn On/Enable NIC called "eth0".
route -n Find network gateway.

Configuration Files And What They Do

File / Path Info
/etc/apache2/ Apache HTTPD configuration files.
/etc/fstab List of devices and their associated mount points to be automatically mounted at system startup.
/etc/hosts A list of all known host names and IP addresses of the machine.
/etc/hosts.allow List of hosts that are are allow to connect to the system.
/etc/hosts.deny List of hosts that are not allowed to connect to the system.
/etc/hostname Contains full hostname (system name) including domain.
/etc/mdadm/mdadm.conf Linux software RAID configuration file with mdadm.
/etc/motd Message of the day broadcast to all users at login.
/etc/network/interfaces Network interface configurations (NICs). This is used to automatically configure NICs at system startup.
/etc/php5/ PHP configuration files.
/etc/profile System wide environment variables for all users.
/etc/nginx/ NginX configuration files.
/etc/resolv.conf Defines IP addresses of DNS servers.
/etc/samba/smb.conf Config file for the Samba/CIFS server. Provides active directory, file sharing and print services to clients.
/etc/systemd/system/ Systemd units, timers, targets and wants files.
/etc/udev/rules.d/ Udev rule files for dynamic device management.
/var/log/ System log files.

File Permissions

If the command "ls -l" is given, a long list of file names is displayed. The first column in the list details the permissions applying to the file. If a permission is missing for the owner, group or other, it is represented by a "-" (e.g. drwxr-xr-x).

linux-file-permissions-diagram.png

Command Example Info
Read = 4 File permissions are altered by giving chmod command and the appropriate octal code for each user type (e.g. chmod 764 filename will make the file called "filename" "R+W+X" for the owner, "R+W" for the group and "R" for the others.
Write = 2
Execute = 1
chmod 755 Full permission for the owner, read and execute access for the group and others.
chmod +x filename Make the file called "filename" executable to all uses.
chown owner:group filename Set the "owner" to "owner" and "group" to "group" for the file "filename".

Tips And Tricks

Command Example Info
~ Represents the home directory of the current user.
$ Generally represents the command prompt.
# Generally represents the command prompt with elevated permissions.
* Wildcard - represents everything. For example, "cp from/* to" will copy all files in the "from" directory to the "to" directory.
? Single character wildcard. For example, "cp config.? /configs" will copy all files begining with the name "config." in the current directory to the directory named "configs".
[xyz] Choice of character wildcards. For example, "ls [xyz]*" will list all files in the current directory starting with the letter x, y, or z.
clear Clear the terminal screen.
CTRL - L Clear the terminal screen.
kill 123 Kill a specific process ID "123".
ps List current processes.
top Display operating system processes.

Help

Command Example Info
apropos subject Display the man pages with the "subject" within page names and descriptions.
man -k keyword Display the man pages containing a keyword called "keyword".

Last update: September 24, 2020