Terminal Guide

From GroovixWiki
Jump to: navigation, search
Note: The terminal interface can be a very powerful tool, it is recommended for advanced technicians that are comfortable working with a 'Command Line Interface'.

The terminal command line interface (or terminal) is non-graphical and used by typing individual commands for each task. Tasks such as navigating directories or folders, editing text files, moving/copying files are all done with typed commands. This might seem slow or obsolete compared to a modern graphical interface, but the terminal interface is capable of incredibly complex commands that can automate many tasks with one line of commands. The terminal interface used in Groovix is known as xterm, both terminal and xterm can be used interchangeably. From now on, this wiki will only be using xterm when referencing the terminal interface.

When working with xterm, pay attention to the user; different user accounts have different privileges which can give unexpected results or deny commands. To identify which user is logged in, find the current line in the xterm window; it will be displayed as user name @ workstation name (ex. gvuser@inet-7). To change which user is logged in, type su [username] where [username] is the user you want to log in as and press [ENTER]; log-in will be successful once the password for that user is entered.

Using Commands

Commands follow a simple structure that must be followed to execute the command properly, [command] [option(s)] [*]. All commands are followed by a space if an option is used. Multiple commands can be typed on one line but must be separated by a semicolon.

Note: adding ‘--help’ after a command will display the command description and options available for that command.

Some commands require extra information such as a time or path, these come after any options. For example, the shutdown command requires a time indicated for when the shutdown should occur (ex. shutdown -r now).

Command History

All commands entered are saved in a history that can be quickly accessed by using the [UP] and [DOWN] arrow keys on your keyboard. This is helpful when repeating similar commands in a sequence or save time on commands typed frequently. Each press of the [UP] arrow scrolls through past commands, starting with the most recent; each press of the [DOWN] arrow advances forward to the next command in your history until the most recent. Once you have reached the most recent entry, pressing the [DOWN] arrow key once more will exit searching the history, and return you to a blank line to enter a new command. You can execute any command in your history by first navigating with the [ARROW] keys and pressing [ENTER] when the command you want to execute is displayed.

Recursive History

Having a command history is incredibly useful, but since it's displayed in a chronological order, can become difficult to search through after many commands have been entered. Recursive searching helps give you a result of a previous command you used based on the command itself, instead of the time it was entered. For example, using the arrow keys, navigating 50 entries deep to get to a command entered a few days ago would take quite a while. Using recursive search allows you to type the first few letters of the command and search though the entire history at once, bringing up commands that start with those characters until you find the command you are looking for.

To use the recursive search, press the [CTRL] key and the [R] key at the same time, then start typing the command you are looking for. Press [ENTER] when you want to execute that particular command.

Using Options

Options are used to customize or specify how a command should execute. Options are always typed with a hyphen followed by a single letter with no space (ex. -r). Multiple options can be used in a single command by spacing between each option (ex. ls -l -r).

Note: options can be case-sensitive, -r and -R are not the same to xterm; this can give unexpected results.

Common Commands

cd              command alone will navigate to the root directory, add a path to navigate to a specific folder (ex. cd /etc/Groovix/)
clear           clears the screen of previous information
cp              make a copy of a file
eject           ejects a CD-ROM or removable device
exit             closes an xterm window (also used to log out of an SSH session)
ifconfig        displays network adapters and their properties
ls                lists files and folders in the current directory
more           outputs large file contents one page at a time, spacebar will advance one page until finished
mv              move a file
ping            pings a system Note: filtered webs will not respond
rm              delete a file
shutdown    shuts down the computer (requires a time) (-r option to reboot, -h option to halt)
su              switch user
xkill            changes the mouse cursor to an x, click on a window to close that window/program

Copy and Paste

To copy text in an xterm window, highlight the information to be copied and click the middle mouse button at the end of the highlighted text. To paste text in an xterm window, click the middle mouse button, the text will be pasted wherever the cursor is.

xterm Tips: - the up and down arrows cycle through previously entered commands - the tab key will auto complete a file or folder name based on the first few characters typed.

Editing text files

There are two types of text editors to use in xterm; vi and nano. To use nano, type nano [filename] where [filename] is the file you would like to open and press [ENTER].

The terminal screen will be replaced by the contents of the file, at the bottom (in red) are the commands available. Each command is represented by a ‘^’ and a letter (^ = CTRL); press both [CTRL] and the letter to perform that command. To quit the nano editor, press [CTRL+X]; if prompted to save changes press [Y] for yes, [N] for no. If yes is selected a path to the document is displayed, to save to another location type the path, otherwise, press enter to overwrite the file you are editing.

The vi editor is an advanced text editor, it is recommended to use nano unless you are familiar with vi. To use vi, type vi [filename] where [filename] is the file you would like to open and press [ENTER]. To quit the vi editor type :q and press [ENTER].

Killing a program

The ‘kill’ command is used to forcefully end a process that is not responding. Technicians can kill the inactivity or session timer(s) when working on a particular workstation and don’t want to be bothered with timers or pop-ups.

To kill a program you must first find the process ID (PID); type the following command to receive a list of processes and their PIDs ps aux. The first column is the user running the process, the second column is the PID. To kill a particular process type kill [pid], if the process refuses, type kill -9 [pid] for a more forceful attempt.

If you know the name of the application you want to kill, you can add the grep command followed by the program name to only display that program. For example, to search for the PID for Firefox, type ps aux | grep firefox; this will display results for any application named firefox.

To kill just the inactivity timer, type kill xautolock, type kill pacrez to kill the session timer.

Killing a program in the Groovix GUI

If you can’t find the PID or have the process you want to kill open in the desktop, open a new xterm window and type xkill; this will change the mouse cursor to an X and will kill the first process window you click on with your mouse.