Linux

Getting Started with Unix

We assume you have some familiarity with computer terminals and how to use them, Getting Started with Unix.

Some prerequisites about terminals and typing:

The Unix system is full duplex: the characters you type on the keyboards are sent to the system, which sends them back the terminal to be printed on the screen. Normally, this echo process copies the characters directly to the screen, so you can see what you are typing, but sometimes, such as when you are typing a secret password, the echo is turned off so that characters do not appear on the screen.

Commands Description
ls List name of all files in the current directory
ls filename List only the named files
ls -t List in time order, most recent first
ls -l List long: more information; also ls -lt
ls -u A list by time last used; also ls -lu, ls -lut
ls -r List in reverse order; also –rt, -rlt, etc
ed filename Edit named file
cp file1 file2 Copy file1 to file2, overwrite old file2 if it exists
mv file1 file2 move file1 to file2, overwrite old file2 if it exists
rm filenames Remove named files, irrevocably
cat filenames Print contents of named files
pr filenames Print contents with header, 66 lines per page
pr –n filenames Print in n columns
pr –m filenames Print named files side by side (multiple columns)
wc filename Count lines, words and characters for each files
wc –l filenames Count lines for each file
grep pattern filenames Print lines matching patterns
grep –v patterns files Print lines not matching patters
sort filename Sort file alphabetically by line
tail filename Print last 10 lines of file
tail –n filename Print last n lines of file
tail +n filename Start printing file at line n
cmp file1 file2 Print location of first difference
diff file1 file2 Print all differences between files

The Shell

When the system prints the prompt $ and you type commands that get executed, it’s not the kernel that is taking to you, but a go-between called the command interpreter or shell. The Shell is just an ordinary program like a date or who, although it can do some remarkable things. The fact that the shell sits between you and the facilities of the kernel has real benefits, some of which we’ll talk about here. There are three main ones:

  • Filename shorthands: you can pick up a whole set of filenames as arguments to a program by specifying a pattern for the names – the shell will find the filenames that match your pattern.
  • Input-output redirection: you can arrange for the output of any program to go into a file instead of onto the terminal, and for the input to come from a file instead of the terminal. Input and output can even be connected to other programs.
  • Personalizing the environment: you can define your own commands and shorthands.
Tags

Related Articles

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Close

Adblock Detected

Please consider supporting us by disabling your ad blocker