Basic Unix User Commands
Option arguments are in brackets , and user supplied arguments are italicized. REMEMBER, unix commands
are CASE SENSITIVE!!!!!
- man [section#] commandname
Look up a specific command in the online Manuals. This will give you all the options/switches available
for the command, and the proper syntax for its use. Manuals are grouped into sections, and if the command
is located in a specific section, you may have to include the section number in order for the man command
to find it. If you don't know the command name you are looking for, use the keyword search option instead
- see below.
- man -k keyword
Use a keyword search of the manpages to find all commands pertaining to that topic.
Users and User Maintenance Functions
- Logs you out of the system if you are at the system prompt
See who is currently logged into this system
Show processes (kind of like a task list).
Type man ps at the prompt to see what switches can be used with this command. The -l switch lists the processes
in long format on both a PC and a Macintosh. The -a switch is helpful to use on a Macintosh. Pay particular attention to the PID number for each process. That will be necessary for the kill command described below.
Terminate a process. Use man kill to obtain more information about use and switches for the kill command. Typically, use the kill command as follows: kill -9 PID
where PID is the process identification number obtained using the ps -l command. CAUTION: Avoid killing the process associated with ksh unless you want to kill the session (i.e. logout/exit).
- the .profile file
The .profile file is a hidden file that contains options that can be set by the user and commands that are executed each
time the user logs in. It is comparable to the DOS autoexec.bat file, or the VAX/VMS login.com file. To
customize your login environment, you may modify this file.
- ls [filename]
Basic list of files in the current directory (non-hidden files), or the specific filename (if provided).
Other options/switches you can use with this are:
||long list (same as ll command below)
||all files, including hidden files (those that start with ".")
||list files in date order (newest files first)
||list files in reverse date order (oldest files first)
||recursive list of all files and any files in subdirectories
Long list of files in the current directory, with information such as date, size, ownership, protection,
etc. included. Options listed for the ls command (above) may also be used here. This command does not necessarily work on a Mac running OS X.
- edit [filename]
Edit a file using the Pico (Pine) editor (system default editor). The installed editor will vary
from site to site. JMU has chosen Pico in addition to the traditional vi editor.
- vi [filename]
Edit a file using the vi editor.
- file filename
The system's best guess as to what type of file it is. Wildcards permitted.
- less filename
Display the contents of a file on the screen, page by page with the additional ability to use vi editor
commands to move UP and DOWN through the file. (space to page down, "b" to go back a page).
- cat filename
Display the contents of a file on the screen - NO PAGE BREAKS
- grep pattern filename
Search a specific file(s) for the specified pattern. If the pattern contains special characters, enclose
it in quotes "". Wildcards are permitted in the filename.
- cd directory
Change directory to directory
- cp filename1 filename2
Makes a copy of filename1 with the name filename2
- rm filename
Delete (remove) filename
- mkdir directory
Make directory directory
- rmdir directory
Remove directory directory
- mv filename directory
Move file filename to directory directory
- mv directory1 directory2
Rename directory directory1 to directory2
Report disk usage, summarized by subdirectory
If you typed a command incorrectly, the arrow keys will not necessarily work to modify what you have typed. However, the following may be helpful when changing something you have typed on the command line:
- Ctrl-W (PC & Mac) clear line
- Ctrl-I (PC & Mac) tab forward
- Ctrl-H (PC & Mac) backspace
GNU C compiler