Xubuntu

Chapter 14. The command line

Table of Contents

Running commands with administrative rights
Common commands

While Xubuntu, including the default applications and the applications in the Ubuntu repositories, comes with graphical user interfaces to accomplish most tasks, sometimes you might want or need to use a command line to achieve your goal - or just achieve it faster.

To start the default terminal emulator and get to the command line, either:

There is a great tutorial on using the command line in the Ubuntu community wiki.

Running commands with administrative rights

When working on the command line, any command can be run as an administrator by prefixing the command with sudo. Sudo will remember your password for 15 minutes to allow you to perform multiple administrative tasks without being prompted for a password each time.

[Note]

If the program you wish to run as an administrator is graphical, such as the Mousepad text editor, run the command prefixed with pkexec in the command line. For example, to run Mousepad with administrative rights, run the command pkexec mousepad /path/to/file.

[Note]

Please note that for an application to run successfully with pkexec, it will need to ship a pkexec policy file. All default applications in Xubuntu that might need to be ran with administrative rights come with pkexec policy files.

[Warning]

Be careful when using sudo; you might damage your system if you type the wrong command! As a general rule, only use sudo when absolutely necessary. When you use sudo from a terminal, be sure to either close it when you have finished, or type exit to continue using that terminal with normal access powers.

For more information on sudo, see the sudo page on the Ubuntu community wiki.

Common commands

Basic terminal commands are outlined below (square brackets indicate substitutions):

Command What it does? Syntax
apt-cache Shows information about the packages in the repository. Common commands are the search and show commands apt-cache search web browser or apt-cache show firefox
apt-get Manages packages in apt. Common commands are install to install a package, remove to remove a package, purge to remove a package and the configuration, and autoremove which will also remove unneeded packages apt-get [command] [package]
cat Joins (concatenates) two or more files cat [file1] [file2] ... > [output file]
cd Changes to another directory cd [directory]
cp Copies a file (or files) to a directory or to overwrite another file cp [file(s)] [directory]
date Tells you the date and time in many different formats, timezones, and conversions. date [options]
editor Opens a text file in an editor editor [file]
grep Searches strings or files grep [text] [file(s)] or [command] | grep [text]
kill Terminates programs with a specified PID. If you don't know the PID you can use pidof kill [-SIGNAL] [PID(s)]
killall Much like the one above, except you specify the programs name killall [-SIGNAL] [process(es)]
less Shows the contents of a text file less [file]
ls Lists files in a directory. Lists files in the current directory if none is specified ls [directory]
man Shows help about a command man [command]
mv Moves or renames a file mv [filename] [newfilename]
rm Removes files or directories. Be very careful with this command! With the -r option, it removes all files and directories recursively! rm [file(s)] or rm -ir [dir(s)]
wget Downloads files to current directory. The -N option can be useful for checking to see if a file on the server is newer than the one you have locally, see man wget for more information. wget [urls]