Starting a program, file management, system monitoring and more can all be performed without a single mouse click. Some swear by the command line, while others are happy never to have to encounter that intimidating black screen. If you’re the curious type and want to explore the full power of your Linux system that your GUI conveniently hides, then read on.
Most of us are familiar with using what is called a Graphical User Interface (GUI), be it GNOME, cinnamon, XFCE, or KDE based, to navigate our computers. What beginners don’t realize, is that underneath that interface, lives the Linux command line. Those coming from the Windows world may easily confuse the DOS window with the Linux command line, but the two are worlds apart in terms of structure and power. Using the command line, you can issue commands directly to the computer to perform tasks that you’d normally complete with a mouse. And more so – the command line interface is in fact often the fastest way.
The shell is the piece of the puzzle that actually does the work. It takes the commands you type in and hands them off to the operating system for action. Bash (which stands for Bourne Again Shell), is the default shell program for most Linux distributions. There are many others though, kshh, tcsh and zsh to name a few.
Under Linux (fex. ubuntu), you can launch the terminal through the Applications menu, under Accessories or by hitting Alt+F2 and typing “terminal”. Other distributions may have the launcher located elsewhere. It could be called terminal, konsole or Xterm, but the icon is usually a black computer screen.
When you launch a terminal window, you’ll see your name, followed by your computer name and either a $ (logged in as user) or # (logged in as root).
The ~ indicates that the working directory is now the username’s home directory.
Filenames are case sensitive and extensions aren’t mandatory. Root is represented by a forward slash (/) followed by directories. Example:
Since Linux is Open Source software by nature, one important rule to remember is that everything is a file, and most files in Linux can be viewed as plain text. There are several ways to edit these files, but if you’d just like to view them, here are the 2 most simple:
Here is a subset of commands that you’ll find yourself using most:
pwd – prints your working (or current) directory
cd – change directory
ls – list the files in the working directory
cp – copy files and directories
mv – move or rename files and directories
rm – remove files and directories
mkdir – create a directory
Different types of viewing text files with:
more (less is better than more)
Two most common text file editors:
Normal users are not authorized to perform any system operations. If a normal user needs to perform any system wide changes, the user needs to use either ‘su‘ or ‘sudo‘ command.
To become temporarily root or superuser:
To become root or superuser:
In general, most commands follows this syntax:
command -option1 -oprtion2 name-of-directory-or-file
ls -lia /directory
Another way that Linux differs from Windows is in its ability to have multiple users working on the same pc at once. In order to manage this tricky process seamlessly, you can use permissions.
Here are some basic permission commands:
chmod – chmod is used to change the permissions of files or directories.
chown – to change ownership of the file or directory
chgrp – change a file’s group ownership
When troubleshooting your Linux box, system information is often the first piece of information you’ll need to know. The kernel version, partitions and other hardware information can easily be obtained from the command line. This is just a sample of commands for viewing system information:
uname – show kernel version and system architecture. (several options available including -s – kernel, -o for operating system. -a prints all options)
lspci -show PCI info
lsusb –show USB info
df -h –display free disk space on mounted filesystems
fdisk -l –show disks partitions sizes and types (run as root)
Linux Command Line Resources
A full list of commands is available at the Linux MAN pages.
In terms of Linux command line functionality, I’ve barely skimmed the surface here. Unlike in Windows, you can actually change almost everything in Linux by using the command line interface, and there are times where it is possible that your GUI can become inoperable. Knowing how to navigate the command line will ensure you can troubleshoot, access and possibly backup your system.
Additionally, for those inclined to truly understand the inner workings of their Linux OS, mastering the the command line is a hard-earned right of Linux passage.