NOTE: Within this tutorial, we use the % symbol at the beginning of the commands listed here to represent the shell prompt.

When using Unix commands, you must remember that nearly all Unix commands are composed of a command, a few flags, and an argument of some kind. They look something like this:

% command -flags [arguments]
COMMAND
A command is a small program designed to do one thing and do it well. Typing in anything on the command line of the Unix shell causes it to search its PATH for an executable file matching that name. When it finds one, the shell passes the command to the kernel for execution, along with any arguments supplied on the command line with the name of the program. Typing in a 'command' simply launches a program by the same name. Most programs are stored in the binaries directory on a Unix system (/bin, /usr/bin or /usr/local/bin). For a command to be found, you must place the directory in which it resides in the PATH environment variable.
FLAGS
Many commands have optional functionality that can be switched or set using a flag. Flags are typed in with the command on the command line using an indicator character that distinguishes the flag from other data to be submitted to the command. For the vast majority of Unix commands, this is the hyphen character; eg. -f, or -a. Flags are not standardized so each command is slightly different. It is frequently a good idea to check the man page before running the command. Many Unix commands have built-in help and won't run, but will but show the command syntax if entered on the command line by itself with no arguments or the -h flag (--help in many versions of Linux).
ARGUMENTS
An argument is a piece of information you want to pass to the command. Sometimes this is just a word, sometimes this is a file name. Passing a file name as an argument usually results in that file being sent to be processed by the command.

COMMON UNIX COMMANDS (System V)

Accessing the System
Command Requires Root Description
login no

The login program is executed by the kernel when it detects someone trying to log in at the console (on the keyboard/monitor attached directly to the computer). A username and password are typically required. This command is not normally issued by the user.

rlogin no

rlogin computername | IP address

Users can issue the rlogin command to log into a different Unix computer from a local Unix computer. It is possible to use this command to log into the local computer as a different identity.

ssh no

Secure Shell

This is an encrypted form of telnet and is also an Internet Protocol application. SSH requires a key on the local and remote computer to verify identity and to encrypt the data being passed during the sesion.

su no

su [-] identity

Switch User

This allows a user to change between login identities. This is one method used to establish root/wheel account access, since it is considered poor security practice to allow root login to a machine directly from remote.

telnet no

This is an Internet Protocol based application that allows a user to connect remotely to a machine and is supported on most computer systems, not just Unix computers. Telnet creates an IP connection to the remote system and the remote Unix system typically launches the login program to authenticate the user.

FILESYSTEM COMMANDS
Unlike Microsoft's DOS, there are very few 'embedded commands' in the Unix Kernel and the Kernel does not directly manage the file system, though it does control access to the storage devices. Thus, there are many small programs developed over the years for displaying and working with files and the filesystem. Here is a list of the most commonly known and used. The filesystem includes the idea of 'ownership' by either a user, the user's group or tye system. There is also the concept of 'permissions' which controls access to the file.
Command Requires Root Description
cat no

cat file1 file2
Join file 2 at the end of file 1

cat filename
Display a file on the screen

cd no

change directory

cd ~
Change to user's home directory

cd /
Change to the local system root directory

chmod no

Change Mode

Changes the access permissions on the inode for the file. This affects who can access the file. The chmod command can use a three or four digit octal value to represent the settings in the file.

Example:

chmod 700 filename

Changes sets read write and execute permissions for the owner (user) of the file.

chgrp no

Change which group owns the file.

chown no

Change the owner of the file.

cp no
cp file1 file2

Copy file1 to file2. Useful when you need to save the current version and work on a separate copy of a file.

df no
df -k

Show the ammount of disk space free. Shown in blocks normally. With the -k flag, shown in kilobytes.

ls no
ls [flags] /path/directory

Lists the files in a given directory as specified by the path. Flags for this command include:

-a  Lists all files, including hidden files
-l   Display files in 'long format' which includes ownership, permissions, file size and date/time information.

mkdir no Make a directory
rm no
rm -f filename
rm -r directory
The rm command remove files; -f removes the viles without verifying, -r removes files recursively down from that location in the filesystem.

WARNING: NEVER USE  rm -rf  or you will wipe EVERYTHING from that point in the disk downwards!! This is DEVASTATING when performed in the root directory, and logged in as the wheel (root user) account.

rmdir no

rmdir <directory list>

Remove Directory

SYSTEM MANAGMENT COMMANDS
Command Requires Root Description
clear no Clears the screen
fsck  
fsck <device>

File System Check
Scan for surface and filesystem errors on a storage device

grep no
grep <file> <regular expression>]

Get Regular Expression Processor

This is one of the most useful tools in Unix, and completely absent in Windows and MacIntosh (prior to OS X). This tool allows you to search the output of a command or a file for a particular pattern. The grep command uses 'regular expressons' as it's pattern.

less no
less <filename>

This is a more advanced version of the more program. This program pauses the output when it fills the display screen. Similar to the 'more' command, however less allows the user to scroll up and down through the data and to search through the displayed text using regular expressions for specific values.

more no
more <filename>

This is the original 'pager' program. Any data stream dumped into it is displayed on the screen and scrolled until the window is filled, at which point the word "--more--" is displayed. Pressing any key displays the next screenful of text (the next page). This can be used to pauses the output of commands such as ls.

passwd no

Changes passwords. Only requires root access if the password being changed is not your own.

ps no
ps -u <username>

Process Show - Show all running processes under a username. Works only on your own username unless you are using the wheel account.

ps -eaf
Show all running processes on the system
top no

Shows the processes running on the system, organized by CPU utilization. This is usually an add-on in Solaris systems.

tail  

Shows the last lines in a file. Used with the -f flag, can be used to monitor the end of a file for new addtions. This is useful when the system administrator wishes to visually monitor syslog files or other system logs for errors.

w   Shows who is logged in
who  

Shows who is logged into a particular system.

System Administration Commands
Command Requires Root Description
useradd YES

Must be root to use this command.

Adds a user account to the system. User accounts have identifier numbers or User IDs (UID). User accounts are assigned values greater than 99 on Linux systems and 500 on Sun Unix systems. Typically, users are assigned the next highest number available on the system. The numbers below 100 are reserved for special system accounts.

usermod YES Modifies a user's account settings. Must be root to use this command.
userdel YES Removes a user's account
groupadd YES

Adds a group to the system. Users are members of groups and groups can be assigned access permissions to varous files. In this manner, files can be made available to groups of people. Many Unix systems come with a default group called 'staff' already installed.

su no

Switch User

This allows a user to change between login identities. This is one method used to establish root/wheel account access, since it is considered poor security practice to allow root login to a machine directly from remote.

     

 


Bookmark this page and SHARE:  

Search

Support InetDaemon.Com

Get Tutorials in your INBOX!

Free Training

Free Training