Revision of Introduction to the Command Line from Sat, 01/11/2014 - 21:12
The revisions let you track differences between multiple versions of a post.
This manual covers the basics of using the command line.
What is the Command Line?
The command line is a direct interface between you and your operating system. It is commonly used for programs that don't have a GUI (graphical user interface) or programs that are meant to be run only in the command line. It is also commonly used to hand edit the files and settings of your operating system (think of getting under the hood of your car).
Why Should I Use the Command Line?
- There are programs that have no GUI.
- It can be faster and more efficient than using a GUI for some tasks. Some programs have a GUI, but can be run in the command line to get the job done better or easier.
Accessing the Command Line
Accessing the command line differs from desktop environment to desktop environment. You will need to locate a terminal emulator (abbreviated as "terminal")
GNOME (default Trisquel):
- Applications menu -> Accessories -> Terminal
- Keyboard Shortcut: Ctrl + Alt + T
LXDE (Trisquel Mini):
- Menu -> Accessories -> LXTerminal
Xfce:
- Applications menu -> System -> Terminal
KDE:
- KMenu -> System -> Terminal Program (Konsole)
Inside the Command Line (Prompt)
Regardless of what desktop environment you use, you should see a window similar to the one below:
- trisquel: This is the username of the account you are using.
- laptop: This is the name of the computer you are logged into.
- ' : ' : Everything after this colon is going to deal with where the current location is.
- ' ~ ' (Tilde): This represents the home directory (all of your personal user files are kept here).
- ' $ ' : The prompt ends in this character. If you are logged in as a super user (like root), the prompt will end with '#'.
Using the Command Line
- Type in a command and hit enter.
- Some commands are interactive, meaning that the program will ask for extra input (yes/no, passwords, text, arguments, etc).
- Command line programs commonly come with manuals ("man pages"). You can read "man pages" by typing in "man ''[command]''". For example, the command "man apt-get" will return information on how to manage your packages (programs) via the command prompt.
- Press 'q' to exit the man page.
- Do not blindly enter commands without knowing what they do. Even small commands can do damage to a system.
How to Become a Super User
A super user is a user that can administrate system-wide settings on the computer. For example, installing software is system-wide and will affect all users, and hence requires super user privileges.
In Trisquel, the default user is given sudo
privileges, which means that user has to re-enter their own password to become a super user temporarily. This is a much more safe approach than being a super user all the time (which should be avoided). An example is provided below:
sudo apt-get install apache2
The above command, when typed in a terminal, will use the apt-get program to install the "apache2" package. To run a program as a super user, simply run sudo [program] [parameters]
.
New users created in Trisquel won't have sudo privileges by default. To give a new user sudo privileges, do the following:
- Type
sudo adduser [newuser]
, substituting [newuser] with the name of your new user. - Use the default user to run
sudo visudo
. - Use the down key on your keyboard to scroll to the bottom.
- Type the following text at the end of the file:
- [newuser] ALL=(ALL) ALL
- Press CTRL+X to exit, and hit Y to save. Backspace the ".tmp" part of the filename, so it is /etc/sudoers
- Hit Y to override the file
When you login to your new user account, it will have sudo privileges.
Su
The su
command is a way of becoming a super user by using the root account's password instead of your own. To use it, enter su
in a terminal and enter the root password. A # symbol should appear at the end of the prompt, meaning all commands from here on will be run as a super user.
To exit su, type exit
. You will see the $ symbol, meaning that you are now a normal user again.
Additional resources
This manual is only an introduction to the command line. If you are interested in learning more, consult the documentation below: