Command Line Essentials Part 3


This is Part 3 of Command Line Essentials(Part 1, Part 2). In this Part I will be focusing again mainly on common utilities. Utilities are what command line programs are called.

Man Pages, ect

This is meant as a basic tutorial, mostly to show what there is to use. It is by no means comprehensive. There I many useful things I omit. You have to learn more on your own. Use man, info, –help, or the internet. It is good to know how to find information when you need it.

Aborting Execution with Interupt Keys

You can use key commands to do certain things. Ctrl-C stops a program. Ctrl -Z suspends a program. It will dispay something like:

[1]+  Stopped                 vi

You can enter fg %1, the number after the % being the number in the message. fg with no arguments will bring back the most recently suspended program.

Pipes

Pipes allow you to connect commands. It takes the output from one command and puts it into the input of the other. It uses the vertical bar(|), normally above the enter key. For example(more on sort in a bit):

$ sort phone_nums | less

This command first sorts the file called phone_nums then sends it to less to be viewed.

More Text Utilities

Some things not covered in Part 2.

sort

sort sorts, astoundingly enough. It puts the text file in order by its lines and displays it. (It does not change the file.) There are also more sorting options.

todos/fromdos

By now you may have realized that everyone has their own way of doing things. Because of this Windows text files don’t work right on Linux and visa versa. todos converts into a Windows friendly format and fromdos converts it into a Linux friendly format.

Compression/Archiving

gzip/gunzip

gzip(GNU zip) compresses a file. The result is a file(smaller) with a .gz extension. Note that it only compresses files, not folder(see tar). (for windows compatibility look up the zip utility)

tar

Tar can do many things. is core purpose, nowadays anyway is to make one file out of many files. For this utility I will introduce the common options first then give examples.

-c(create- to make a tar file)    -v(verbose- says everything that’s happening, not especially useful)    -f(file)    -x(extract the files)    -z(uses gzip/gunzip in addition to tar)

Other Stuff

date

Gives the date and time. There are some advanced options for formating.

file

file gives information about a file.

locate

locate searches for a file. Used: locate thisorthat.  You may find a huge number of files

Notes

Conventions

Commands and terminal examples are in monospace. User typed input is in bold.

Getting to the Terminal/GUI

In most Desktop environments: Applications -> Accessories -> terminal. In Unity search for terminal.

You can also use run(alt-f2) and type in gnome-terminal or xterm or something similar.

Other

Many(or maybe most) of these commands are also in Mac OS, but since I have no experience with Macs I do not know the specifics of how it differs.

Advertisements