CSC 2400 Activity – Useful Unix

 

Unix and Linux consist of a very large collection of utilities, features and commands. Here are a few of the most useful and interesting to get started.

 

1.     Tab completion

When typing a command, you can type the first few letters and hit the Tab key, and the system will complete the rest for you.

 

2.     Up & Down arrows

Use the up and down arrows to go back thru the history of the commands you have recently typed. When you find one you want to reuse, just hit Enter and it will run the command. It saves a lot of time retyping commands, especially complicated or long ones.

 

3.     Manual page

To read the manual page or “man page for any Unix/Linux command, type this:

man name_of_command

For example, if you want information on the “clear” command, type:

man clear

 

4.     Finding a command when you dont know its name

The “apropos” command will let you search through all of the command names and descriptions, helping you to find a command when you dont know its name, like this:

apropos user

 

5.     Getting out of things (Ctrl-C)

To exit out of just about any running program, such as when something is taking too long or seems to bestuck,” hold down the Ctrl key and hit the C key. This is called hitting “Control C.

 

6.     Display a simple calendar

To display a calendar for the current month or a specific month and year, for example, use these three variations of the calcommand:

cal

cal 9 2015


7.     Clear the screen

To clear the screen, type:

clear

 

8.     Send or “pipe” the output of one command into another

You can pipe output from one command to another using the pipe character, which is |. For example, if the output of “apropos was very long, you could search through the output for just the command that have the word display in their name or description using the grepcommand like this:

apropos user | grep display

 

9.     Searching for text in a file or output

The grep utility is very powerful, and you should check out the man page for it to find out more. To use it in a simple way to search through a file or the output of another command, type one of these commands:

apropos user | grep display grep wha /usr/dict/words

 

10.  Seeing who else is logged in

To display a list of users who are logged in to the same machine as you, type one of these:

who users

 

11.  Finding out who you are

To see the username by which you are logged in, type this:

whoami

 

12.  Create a small file

To create a small file just to have a file to work with, such as to practice commands to copy or move files, type this:

 

echo “hello” > smallfile.txt

 

This activity will not be graded.