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:
For example, if you want information on the “clear” command, type:
4. Finding a command when you don’t 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 don’t know its name, like this:
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 be “stuck,” 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 “cal” command:
cal 9 2015
7. Clear the screen
To clear the screen, type:
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 “grep” command 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:
11. Finding out who you are
To see the username by which you are logged in, type this:
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.