Karla News

Basic Terminal Commands for Linux

GUI

One of the biggest reasons to use Linux, an one of the most important tools if you do choose to do so, is the command line, or the terminal. This is a completely text based tool, and is far superior to using a graphical user interface (GUI) in many situations for a large number of reasons. Some of these reasons include increased flexibility, decreased time moving between the keyboard and mouse, it even is an excellent tool for administration for lack of distraction, etc. Whatever your reason for wanting to use the terminal, there are certain basic commands that you must know before you can learn anything else. Here is a list of ten command groups:

man/info- These are your basic how to and tutorial commands. If you’re lost with another command or something and don’t know what to do, just type into your terminal man or info followed by the command name (for example man info will give you the manual, or man, page about the command info). This will work for most things and even, sometimes, other bits and pieces about your Linux distribution. They occasionally have different information from each other, so if you still don’t get it after trying one, it can’t hurt to try the other. These commands don’t really have any necessary options.

cd/pwd- these commands are both used for the working directory, or the directory to which all of your commands are directed by default. cd (change directory) is used to change your working directory, while pwd (print working directory) is used to display your current working directory. By default, the first directory that is your working directory when you enter the terminal is your home directory, but cd can change it to anything. For example, if you enter the command cd /home/[your name]/Desktop, now your working directory will be your desktop. At any time, if you get lost and your terminal is not set to tell you your working directory in the prompt, merely typing pwd will tell you what it is. These don’t really have any important options either.

See also  How to Speed Up Windows 7 Boot Time

ls- Another important command is ls (list). This command, without any options, displays the files in your current working directory, minus the files that are preceded by a period (dot files). Depending on what terminal program you are using, the list may be in different colors or highlighted based on the filetype or if it is a directory. Some important options for this command include -a (which displays dot files in addition to everything else), -l (gives additional information, including file size and file permissions), and -h, which makes the sizes easier to read when you use the -l option.

Sudo/su/gksudo- Based on your distribution, one of these commands, or two, will be used to run a command as a root user. Sudo, if it precedes any command, is used to turn only that command into an administrator-run command, by default. The terminal will prompt your for your password, the command will be run, and then for a preset period of time, you will not need to re-enter your password when you precede a command with sudo. This is normally for fifteen minutes. Su does the same thing, but makes everything you do for a preset period of time done with administrator privileges, meaning that you don’t have to precede commands with sudo and you can do things outside of the terminal. Finally, gksudo is what you should use if you are doing something in the gui that requires administrator privileges. For example, if you do an alt-f2 command and want to run a gui backup utility you would type gksudo [utility name] and it would prompt you for your password. There is also a gksu command that works in a similar way. The options for these utilities are extremely complicated. See man sudo, etc.

See also  Understanding and Using Diegetic and Non-Diegetic Sound in Filmmaking

mv/cp- These two utilities are used to respectively move and copy files and directories from one place to another. They both work by inputting mv [filename, either absolute or relative] [location, also absolute or relative]. (The difference is that an absolute filename starts with the root directory /, while a relative starts from your working directory.) These work otherwise the way you would expect. Some important options include -f, (force) which overwrites any existing file with the same name, -i, (interactive) which asks you before it does anything, and, most importantly -r, which will copy or move recursively. This is what allows you to copy or move an entire directory, in addition to its contents.

cat/less- These are the two most commonly used functions for displaying the contents of a file. Cat displays the entire thing, which is a real problem if your file is longer than a single page. Less, in contrast, is used to tab through a file bit by bit. This is a very logical command, and to move on in the file you can either use the arrow keys, the spacebar, which brings you forward an entire page at a time, or other commands. The only catch for this is that to get out of display mode, you must press q. More is another command that is used for displaying a file, but less is a far more common way to do this (or, as is frequently said, “less is more.”)

mkdir/rmdir- These commands are used for directory management. Respectively, they make and remove a directory. This will occur by default in the working directory, as will most commands, unless you specify an absolute or relative pathname. There are not really any very important options to use for these commands.

See also  Linux Terminal Web Browsers

I hope that this article has been helpful to give you a good basic understanding of terminal commands. Good luck!

Reference: