Basic UNIX Commands

Directory commands

cd Change the working directory

find Find a file by name or by other characteristics

mkdir Make a directory

rmdir Remove a directory

File manipulation commands

cat Concatenate and display a file

head

tail

chmod Change the permissions mode of a file

chown Change the owner and/or group of a file

cp Copy a file

diff Display differences between pairs of text files

grep Search a file for a specific text string

mv Move or rename a file

rm Remove a file

Display commands

date Print the date and time

finger Display information about a user

head Display the first few lines of a file

less Browse a text file

ls List the contents of a directory

man Display a reference manual page

more Display a text file

pwd Display the working directory pathname

tail Display the end of a file

who Display who is on the system

w

last

Process commands

exit Terminate a process

kill Terminate or send a signal to a process

passwd Create or change a password

ps Display the status of a process

telnet Connect to a remote system using the Telnet protocol

logout

File/Directory Manipulation

Manipulating files and Folders in Unix

chmod - change file modification rights

Format
chmod abc filepath

Summary
Changes rights of the file to owner=a, group=b, world=c. Example: 777 =
read/write/execute rights for all, 750 = full rights for owner, read/execute
rights for group, no writes otherwise. Numbers are formed by adding 4 for
read, 2 for write, and 1 for execute.



chown - change owner

Format
chown user:group filepath

Summary
Changes owner and group of the specified file/folder to owner and group.



cp - copy one or more files

Format
cp [options] source-file destination-file
cp [options] source-file-list destination-directory

Summary
The program has two modes. You can copy one file into another. Or copy a
file from one place to another.
You can use wildcards * and ?.

Options
-r    Copies directories recursively. With this i mean that all files
including subdirectories and their content given by source-file-list will be
copied to the destination directory.


df - disk free displays the amount of available disk space

Format
df [options] [filesystem-list]

Summary
If you don't specify the filesystem-list, df will list the amount of
available disk space on all mounted filesystems

Options
-t type, causes df to display information about the type of the filesystems
of the specifies type.


du - disk used

Format
du [directory-list]

Summary
Lists the diskspace used by the directory and its contents specified by the
directory-list argument


find - find a file

Format
find directory expression

Summary
directory specifies the directory where you want the search to start. Find
will search all directories recursively.
expression is the search argument. These are the most common used:
Search arguments
-name filename, searches for the given filename
-user name,     list all files who are owned by the given users
-size +/-n,     lists all files with size smaller/greater than n
-maxdepth n, searches no more than b directories down from current
location

ln - make a link to a file

Format
ln [option] existing-file new-link

Summary
Creates a hard link to the file specified by existing-file with the name
given by the new-link argument. A hard link to a file is indistinguishable
from the original. A hard link has to be on the same filesystem as the
original file. A symbolic link may be across filesystems and existing file
and new-link may be directories as well as files.

Options
-s creates a symbolic link instead


locate - locates files

Format
locate pattern

Summary
Lists all files in filedatabase that match the given pattern.
This utility depends on a database file with al list of all files on your
filesystem. Use the updatedb utility to update your database (caution, this
takes a while)

Example
#locate hepp
This search would find all files on yor system that contain hepp. It would
find heppgr, tghepp and tyheppl.


mkdir - make directory

Format
mkdir [options] directory-list

Summary
Creates a new directory. If you write #mkdir test, mkdir creates a new
directory with the name "test" in the current directory.         
If you want mkdir to make a directory in another directory, you must specify
the whole directory path.

Options
-p parent, if the parent directory of the directory you are creating does
not exist, mkdir will create it for you.


mv - move files

Format
mv [options] source-path destination-path

Summary
Copies the the files specified in source-path to destination path and then
deletes the original files.
You can use wildcards * and ?.


passwd - change password

Format
passwd

Summary
Enter current password, then new password twice for verification.



pwd - path/which directory

Format
pwd

Summary
returns the full path to the current location, such as
/home/users/smith/backups



rm - remove files

Format
rm [options] file-list

Summary
This utility removes files from your system. You can use wildcards * and ?.
Note: when you delete a file it is not possible to recover it.

Options
-r     recursive, this option makes rm remove the specified directory and
all of its contents. (MS USERS: Just like deltree) BE CAREFUL WITH THIS
COMMAND!!
-f     force, this option makes rm delete files without asking you if you
really want to. Nice if you want to delete directories.


rmdir - remove directory

Format
rmdir directory-list

Summary
Removes all directories specified by directory-list.
Note: The directories you want to delete must be empty. If they are not,
mkdir will fail. If you want to delete a directory together with its
contents use rm.

 

Useful Unix Info

Most of the following fill apply to any Unix-based operating system, including Linux and BSD flavors, such as Red Hat, Open BSD, and Mac OS X/Darwin.

General Links

Mac OS X <http://www.apple.com/macosx/>

Darwin <http://www.opensource.apple.com/>

Free BSD Handbook <http://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/>

Introduction to FreeBSD <http://www.vmunix.com/fbsd-book/intro.phtml>

Linux

GNU's Not Unix! <http://www.gnu.org/>

Mac OS X Software

Open OS X <http://OpenOSX.com/> compiles open source software for the Mac and distributes CDs or CD subscriptions. Their products include Open Web (which includes MySQL and PHP), WinTel (an open source Pentium emulator a la Virtual PC), an open source MS Office competitor, and GRASS (an open source GIS program competing with ArcView).

Stepwise

Versiontracker

Sendmail

Building Sendmail Config Files <http://www.nmr.mgh.harvard.edu/Sendmail8.9/ConfigFiles.shtml>

Sendmail FAQ <http://www.sendmail.org/faq/>

Anti-Spam Provisions in Sendmail 8.8 <http://www.sendmail.org/antispam.html>

Sendmail Masquerade Capabilities <http://www.connactivity.com/~esj/sendmail/masquerade.html>

Edit the Sendmail access database to restrict relaying: in /usr/lib/sendmail-cf/sendmail.cf look for a line that tells sendmail where to look for its access database. E.g.:

# Access list database (for spam stomping)
Kaccess hash -o /etc/mail/access

Then look in /etc/mail/access to edit the series of domains or IP addresses which control the server's behavior, such as:

cyberpromo.com 550 Mail rejected due to possible SPAM
public.com 550 Mail rejected due to possible SPAM
129.215.65.51 RELAY
mydomain.com RELAY

IP Firewalls

sasadsdfsdf

Telnet/FTP vs. SSH

Crackers are like cockroaches.

zxczxccxzxc

Apache

Apache Tutorial: Introduction to Server Side includes <http://httpd.apache.org/docs/howto/ssi.html>

Webmaster's Guide to Server Side Includes <http://www.webreference.com/programming/ssi/intro/>

Edit /etc/httpd/conf/srm.conf to alter Apache's behavior. For instance, to create an "alias,"

To set up SSI

Command Line

xvcvzxvc

command-line utilities and non-interactive server programs. In fact, almost every command you type at the Unix command line is a small program, but one you run from the command line rather than by double-clicking. To access Mac OS X's Unix command-line prompt, launch the Terminal application from the Utilities folder in your Applications folder. Type "ls" (without the quotes) to run the program that lists files in the current directory, which is essentially what the Finder does every time you open a new window. Other core commands include more, which displays text files, and man, which displays online help called "manual pages." To learn about each of these commands, try typing "man ls", "man more", and "man man" (once you've started man, press the space bar to scroll, and type q to exit). Hundreds of these small command-line utilities are included with every version of Unix; to see most of them, type "ls /usr/bin".