Monday, December 19, 2011

Basic UNIX Commands - 1

Unix Commands

Note: You can use these commands at the Unix system prompt.

| more

the pipe symbol (|), located above the backward slash (\) key, and the word more can be used after Unix listing commands (such as ls or cat filename) to display information one screen at a time (ls |more or cat filename |more). Press Enter or the Spacebar to scroll forward.

banner word

displays the word or words you enter after the banner command in large print. For example, the command banner summer will display the word summer.

cal

displays a calendar for the current month

cal year

displays a calendar for a specific year. For example, the command cal 1999 will display a calendar for 1999.

cal month year

displays a calendar for a specific month and year. For example, the command cal 10 1999 will display a calendar for October 1999.

cat filename

displays the contents of a file

cat filename filename > new file

copies one or more files to a newly created file

cat filename >> destination file

adds one file to another file

cd

moves back to your home directory

cd directory

changes the current or working directory to another directory

cd ..

moves back one directory

cp filename newfilename

makes a copy of a file with a new name. To copy the file to another directory, use the command: cp filename directoryname or cp filename directoryname/newfilename

chmod

changes the read, write, and execute permissions of specified files and the search permissions of specified directories. For example, the command chmod 711 directorypath gives public access to that directory. The command chmod 644 filename also gives public access to the listed file. You must be in the directory where the file is stored.

chfn

allows you to change the information displayed about you when someone uses the finger command with your userID

finger userID

displays login information about the userID indicated

fmt filename > newfilename

sets the width of a file. Filename is the file you wish to format, and newfilename is the filename you wish to give the formatted file. If you bring a file into a mail message, and the lines do not wrap, but instead show dollar signs at the end, this command will set the width to wrap.

getacl filename

displays a list of all the people who read from, write to, and/or execute a particular file in your account. (For more info on this command, see the ACL document.)

head filename

displays the first ten lines of a file

head -# filename

displays the specified number of lines from the top of the file. For example, the command head -8 budget displays the first eight lines from the file titled budget.

history | more

displays of list of the last forty commands issued at the Unix prompt

kill -9 process#

kills a process. (Use ps command to list current processes.)

ls

lists directory contents and file information

ls -a

lists all files including hidden files

ls -F

lists files and subdirectories

ls -R

lists the chain of directories starting from the current directory

ls -s

lists the name and size of each file in a directory

man command

displays information from the online Unix reference manual about a specific command. For example, the command man cd displays information about changing directories.

man -k keyword

displays the commands relevant to a keyword. For example, the command man -k directory displays the commands for working with directories.

mesg n

sets your account to reject talk requests

mesg y

sets your account to accept a talk requests (default)

mkdir directoryname

adds a new directory

more filename

displays a file--one screen at a time

mv oldfilename newfilename

changes the name of a file

mv "filenamewithspace" newfilename

renames a file that has a space or unacceptable character in the filename. For example, the command mv "new budget" newbudget changes the name of the file from new budget to newbudget.

mv filename directoryname/

moves a file to another directory. Directoryname is the destination directory for the file.

passwd

initiates the process for changing your password

pico filename

creates a file using the pico editor

print -Pambler29 filename

sends the file to the Ambler SIC printer

print -Phsc filename

sends the file to the HSC campus printer

print -Ppaley filename

sends the file to the Paley SIC printer

print -Pvm filename

sends the file to the Main campus printer

ps

lists the active processes running in your account. (See the kill command to end a process.)

pwd

displays the current working directory

rm filename

deletes a file in a directory

rm filename1 filename2

deletes more than one file at a time

rmdir directoryname

deletes an empty directory

rm -r directoryname

deletes a directory and the subdirectories and files in the directory

setacl -u user:userID permissions file

assigns rights to allow another person access to a file. In this command, userID is the login ID of the person to whom you want to assign access; permission can be r (read), w (write), and/or x (execute); and file is the name of the file. (For more info on this command, see the ACL document.)

tail filename

displays the last ten lines of a file

tail filename -#

displays the specified number of lines from the bottom of the file. For example, the command tail budget- 8 displays the last eight lines from the file titled budget.

talk userID

initiates a talk request with someone who has an account on the same system

talk userID@system-name

initiates a talk request with someone who has an account on a different system

vi filename

creates a file using the vi editor

webster word

provides the entry from Webster's 7th Dictionary for a word. The entry includes definitions, pronunciation, and derivation.

whatquota

identifies the amount of disk space currently in use in your Unix account

whatquota -mail

identifies the mail spool space currently in use in your Unix account

who

identifies the login name, terminal number, date, and login time for each user who is logged on to the Unix system

write userID

allows you to communicate with another user who is logged on to the same system



















































No comments: