at cd chown dump grep ls man pwd tar who 1.
bg chmode cron diff head lp lpd mv pr tail wall
banner chgrp dd echo kill mkdir news passwd tee touch
cp clear date exit ln mail page or pg rmdir wc talk
cal cmp du find more ps rm write mesg tty
This command is used to scheduled tasks to be at a future date. Syntax at time at [options ] job-ids The system assigns the job ids when you use the at command. Options -l -r time List current jobs Removes specific jobs The time when the command should be run. Unless specify otherwise (with a.m. or
p.m. as a suffix), the system assumes military time. 2. bg bg jobs Places the current job (or, by using the alternative form, the specified jobs) in the background, suspending its execution so that a new user prompt appears immediately. Use the jobs command to discover the identities of background jobs. Resumes a suspended job. Syntax: bg PID 3. banner The banner command creates posters by blowing up its argument on the screen. On each line it can display a maximum of ten characters. Syntax: banner text Example: $ banner UNIX 4. cp - Copy files
Copies the content of one file into another file. Syntax: cp myfile yourfile Example: Copy the files "myfile" to the file "yourfile" in the current working directory. This command will create the file "yourfile" if it doesn't exist. It will normally overwrite it without warning if it exists. cp -i myfile yourfile With the "-i" option, if the file "yourfile" exists, you will be prompted before it is overwritten. cp -i /data/myfile Copy the file "/data/myfile" to the current working directory and name it "myfile". Prompt before overwriting the file. cp -dpr srcdir destdir Copy all files from the directory "srcdir" to the directory "destdir" preserving links (-poption), file attributes (-p option), and copy recursively (-r option). With these options, a directory and all it contents can be copied to another dir 5. cal month year Display the current month in calendar form. Prints a calendar for the specified month of the specified year. Syntax: cal cal month year cal year Ex: cal month year 6. cd - change directories Use cd to change directories. Type cd followed by the name of a directory to access that directory. Keep in mind that you are always in a directory and can navigate to directories hierarchically above or below. Syntax: cd DIRECTORY_NAME Example $ cd progs
7. clear Clears the terminal screen.
8. cmp Compares two files, reporting all discrepancies. Similar to the diff command, though the output format differs. Syntax cmp file1 file2 Example cmp emp emp1 9. chown - change file owner and group Changes the ownership of a given file. There are two commands meant to manipulate the ownership of a file or a directory. They can be used only by the owner of the file (or the system administrator). The chown (change ownership) command gives away the ownership of the file to the user. It accepts as its arguments the login-id of the user to whom ownership is to be given away, along with a list of file names. Syntax: chown owner filename Ex: Chown kumar emp Usage chown [OPTION] OWNER[:[GROUP]] FILE chown [OPTION] :GROUP FILE chown [OPTION] --reference=RFILE FILE Options Change the owner and/or group of each FILE to OWNER and/or GROUP. With --reference, change the owner and group of each FILE to those of RFILE. -c, changes like verbose but report only when a change is made -dereference affect the referent of each symbolic link, rather than the symbolic link itself -h, no-dereference affect each symbolic link instead of any referenced file (useful only on systems that can change the ownership of a symlink)
-from=CURRENT_OWNER:CURRENT_GROUP change the owner and/or group of each file only if its current owner and/or group match those specified here. Either may be omitted, in which case a match is not required for the omitted attribute. -no-preserve-root do not treat `/' specially (the default) -preserve-root fail to operate recursively on `/' -f, -silent, -quiet suppress most error messages -reference=RFILE use RFILE's owner and group rather than the specifying OWNER:GROUP values -R, -recursive operate on files and directories recursively -v, -verbose output a diagnostic for every file processed The following options modify how a hierarchy is traversed when the -R option is also specified. If more than one is specified, only the final one takes effect. -H -L -P if a command line argument is a symbolic link to a directory, traverse it traverse every symbolic link to a directory encountered do not traverse any symbolic links (default)
10. chmod - change file access permissions changes the access permission on a given file. The mode is an o Syntax: Chmod mode filename Usage chmod [-r] permissions filenames r Change the permission on files that are in the subdirectories of the directory that you are currently in. permission Specifies the rights that are being granted. Below is the different rights that you can grant in an alpha numeric format. filenames File or directory that you are associating the rights with Permissions u - User who owns the file. g - Group that owns the file. o - Other. a - All. r - Read the file. w - Write or edit the file. x - Execute or run the file as a program. Numeric Permissions:
CHMOD can also to attributed by using Numeric Permissions: 400 read by owner 040 read by group 004 read by anybody (other) 200 write by owner 020 write by group 002 write by anybody 100 execute by owner 010 execute by group 001 execute by anybody 11. chgrp Changes a file’s group ID, which is used for the group access permission. The chgrp (change group) command changes the group ownership of the file. It shares a similar Syntax like chown, and can be used by the owner of the file who is also a member of the group owning it. Syntax chgrp groupname filename Example To pass on ownership of all the *.lst to bin, you need to use. chgrp bin *.lst 12. cron Tells cron to run a set of commands at specified times. The chronograph of the UNIX system. It executes the commands that are listed in a control file (crontab) at a frequency that is specified by the various fields in the file. The system can get deranged if either cron is not running, or more than one instance of it is active. Syntax cron filename 13. dd This is used to copying the diskettes. dd is a versatile command which is used to perform variety of task. 14. date
Displays the current date. Or if you have superuser status can be used to set the system date and time. System date [options] Option mmddHHMMMMYY Example date 15. du The du (disk usages) command lets the administrator find out more details of disk consumption. This may be necessary when there is insufficient space available, or if the disk is being eaten away very fast. Display how much disk space is used by a directory (and all its subdirectories), in blocks (usually 512 or 1,024 bytes each). Syntax du option directories du options filenames options -a -r -s Display all information Reports on files and subdirectories du cannot open. Silent mode. Display only totals. sets month (mm),date
Example When used without options, it merely reports the space used by the current directory and all its sub directories. #du 16. dump A dump is a long listing of the contents of a file or portions of system memory, produced by the UNIX kernel, under certain system failure. The listing includes the contents of the main memory as well as the state of the system at the time of failure. The information is stored in the file called core file. This file is used for troubleshooting by the system administrator. This file can be found in the working directory of the program that failed.
This command is used to compare the two files. It is used with different options. Syntax: diff options filename1 filename2 Options -b -c -e Ignores blanks at the end of line. generates a context diff. Creates a script for the ed editor to make filename1 same as filename2.
Example diff emp emp1 18. echo command Echoes text to the standard output device. Syntax echo text Example echo good morning 19. exit Quits the current session. The exit statement is used to prematurely terminate a program. Syntax exit Example grep “$1” $2 || exit 3 echo “Patter found – Job Over” 20. find This command is used to find a file. find recursively examines a list of files in a sub-directory to look for a file attribute. Syntax find / -name filename –print Options -print Prints the result of the search Example #find / -name .profile –print /usr/kumar/.profile
/usr/tiwari/.profile /usr/shrama/.profile #_ 21. grep Searches file for a pattern. Syntax: grep options pattern filenames Options -c -l -n -v -i Display count of the number of occurrences Display list of the filenames only. display line numbers along with the lines. Display all but the lines matching the expression Ignores case for matching
Example grep sales emp.lst 2233 | a.k. shukla 1006 | anil agrawal 22. head Displays the beginning of a file. The default is ten lines. Syntax head filename Example1 head emp.lst Example2 head -3 emp.lst 23. kill You can terminate a process by using the kill command. kill a current process by ID number. The command uses one or more PID numbers as its argument. Syntax kill process.id Example1 kill 105 |g.m. |director |sales |12/12/92/6000 |sales |02/09/92/6700
Example2 kill 121 122 125 132 138 144 24. ln Links two or more files. Files are linked with the ln command, which takes two arguments. Syntax ln filename1 filename2 Example To link the files emp.lst with, say employee, you should use ln emo.lst employee 25. lp or lpd UNIX provides a spooling facility by which you can queue up jobs for printing. This is done with the lp(line printing) command. Sends a print request to a printer. Can be used to print multiple files with one request. On some systems, you may need to use the lpr command instead. Syntax lp filename Example lp chap01 Request id is 320 26. ls List the contents of the specified directory. If no directory is specified, the contents of the current directory are listed. Syntax ls names where names refers to filenames or pathnames. Options -a -d -F -g -i list hidden files list the name of the current directory show directories with a trailing '/' executable files with a trailing '*' show group ownership of file in long listing print the inode number of each file
-l -R -t $ ls
long listing giving details about files and directories list all subdirectories encountered sort by time modified instead of name
Example1 Example2 $ ls –x Example3 $ ls –f –x 27. mkdir This command will make a new subdirectory. Syntax mkdir option dirname where dirname refers to the name of new directory. Options: Mandatory arguments to long options are mandatory for short options too. -m, mode=MODE set permission mode (as in chmod), not rwxrwxrwx - umask -p, parents no error if existing, make parent directories as needed -v, verbose print a message for each created directory -help display this help and exit -version output version information and exit Example $ mkdir empdata 28. mail This command is used to send the mail to the a user even if he is not logged in. It is used for non-interactive communication. Syntax mail username Example mail rakesh --------mailing text ------Ctrl+d
29. more Display all or the parts of a file. Type q to quit, spacebar to continue. Used to see the halted output. Syntax more filename Options -c clears the screen before displaying the file.
30. man Display the online-manual page for a command. Syntax man command Example man wc 31. mv command mv command simply renames a file or a group of files. Moves a file or multiple files into another or to a new name in the current directory. Syntax mv filename directory or mv filename newfilename Option -f -i moves file without checking for confirmation in case of an overwrite. Prompts users if action would overwrite an existing file.
Example $ mv chop01 man01 32. news The news command is normally invoked by any user to read any message that is send by the system administrator. Display all news items distributed systemwide. Syntax: news news newsitems Options
-a -n -s
Display all of the news items Display the names of all of the news items. Display a count of all of the news items.
Example $ cat/user/news/dinner News----------$_ 33. page or pg Display a file one page at a time. Syntax pg filename Options +n Starts the display at line number n. Searches for the string string. +/string Example $ pg emp 34. ps Returns the status of all current process. Syntax Ps Options -e -f $ ps 35. pwd You can always find out the directory where you are currently placed, by using the pwd(present working directory) command. Returns current working directory. Syntax: pwd Example Display expanded information about all current process. Display fill information about processes.
$ pwd usr/kumar 36. pr The pr command prepares a file for printing by adding suitable headers, footers and formatted text. Prints a file or files to the default printer. Syntax pr filename | lp Options -d -h text -l -w Double-spaces the text. Prints the header text at the beginning of the output. Sets the page length Sets the page width.
Example $ pr dept.lst 37. passwd Sets the user password. Administrator has privileges of changing anybody’s password without knowing it. Syntax: passwd user Example # passwd kumar Enter new password : <Enter the Password> Re-nter new password : <Reenter the Password> 38. rmdir Removes directories and files within the directories recursively. Syntax: rmdir directory Ex: rmdir amit
Removes files. Syntax: rm filename Ex: rm emp 40. tar Archive files to tar files, often on backup tapes. Syntax: tar options filenames Options c t v x Create a new tar archive write archive to filename, often dev/tape. Print out a table of contents. Verbose mode: print out status information. Extract files from within the tar archive. f filename
Example 41. tail Displays the final ten lines of a file. Syntax tail filename Example1 tail emp.lst Example2 tail -3 emp.lst 42. tee Unix provides a feature by which you can save the standard output in a file, as well as display it on the terminal (or pipe it to another process). It is made possible by the tee command. tee uses standard input and standard output, which means that it can be placed anywhere in a pipeline. The additional feature it possesses is that it breaks up the input into two components; one component is saved in a file which is used as an argument to the
command, and the other is simply connected to the standard output. tee doesn’t perform any filtering option on its input; it gives out exactly what it takes: Example You can use tee to the output of the who command in a file, as well as display it: $ who | tee user.lst One channel is saved in the file user.lst, while the other is displayed on the standard output. you can crosscheck the display with display with the content of the file user.lst. 43. wc Counts the number of words, characters and lines in a text file or files. Print byte, word, and line counts. Syntax wc [options] filenames Options: -c -l -w Ex: wc dept 44. write This is used to have a two-way communication with any person who is currently logged in. Sends a text message to another user. User ctrl + d to exit Syntax write username Example $ write sharma -------message -----o ctrl +d last line of the message should be a single character (perfectly o) to indicate to the receiver that the message is complete. Print the number of characters in a text file. Print the number of lines in a text file. Print the number of words in a text file.
45. who Display the names and other information about users on the system. Syntax who Example $ who 46. wall The wall command has more urgency than the others, as it address all users. Though the command is available in /etc, it can be invoked by any user by employing the absolute pathnames of the command. Example $ /etc/wall -----------message------------Ctrl + d $_ 47. touch The access and modification times of a file change when you try to read or write into it, respectively, you may sometimes require to set them to predefined them. The touch command sets the modification time of the specified file to the current time. Syntax touch <options> <expression> <filenames> 48. talk This is an interactive communication, where two users can chat. Once a user dials another user to chat, he has to respond back by giving talk command, thereby establishing the link for two way communication. Talk command divides the screen into two windows. One for sending message and other for receiving message. Syntax: The specified user has to respond back by issuing talk command and specify and specify the user name, who has send the dial. Example: $ talk ram (send by user1) Ram respond back by giving talk user1 at his prompt.
talk is terminated by either user entering the interrupt key <Delete> in UNIX and Ctrl+c in Linux). 49. mesg Communication, single or two way, can be disconcerting to a user who might be watching the output of a very important program on his terminal at that instant. He is obviously wouldn’t like the screen to be disturbed by such unexpected instruction. In that case he can user the mesg command to insulate himself. Syntax: mesg [options] Options: n – Do not allow messages via write y – Allow message via write Example: $ mesg n prevents other people from writing to his terminal, while 50. tty This command is used to know your terminal number. It is called as teletype command. Syntax tty Example $ tty /dev/tty01 Command Substitution UNIX features the connecting of two commands in yet another way. While a pipe connects the standard output of one to the standard input of the other, the shell enables the argument of a command to be obtained from the output of another command. This feature is called command substitution. When a command is enclosed within a pair of backquotes (‘), the shell executes the command first, and the enclosed command test is replaced by the output of the command. It can be considered to be a case of running a command within another. To consider a simple Example, suppose you wish to echo today’s date with the echo statement. Using the feature of command grouping, you need to issue sequentially the echo and date commands:
$ echo The date today is ; date The date today is Fri Jul 27 00:12:14 EST 1990 $_ Command substitution offers the facility of doing this in a single statement. Use the expression ‘data’ as an argument to echo: $ echo The date today is ‘data’ The date today is Fri Jul 27 00:12:14 EST 1990 $_ Example2 $ echo There are ‘ls | wc –l’ files in the current directory There are 52 files in the current directory $_ OR $ echo “There are ‘ls | wc –l’ files in the current directory”