Download presentation
Presentation is loading. Please wait.
Published byLogan Hutchinson Modified over 6 years ago
1
Agenda Basic Unix Commands (Chapters 2 & 3) Miscellaneous Commands:
whereis, which, passwd, cal, date, ps / kill Working with Files: file, touch, cat, more, less, grep, head, tail, cp, mv, ls sort, uniq, diff Communicating with Users who, finger, talk, write, mesg
2
Textbook Coverage These slides are based on Chapter 3 of “A Practical Guide to Linux” Read pages 41 to 57 6
3
Miscellaneous Commands
whereis which passwd cal date ps / kill
4
whereis / which whereis is a utility that lists all directory paths that contain binary files for a command and directory paths for manuals for a command. For Example: whereis mv which is a utility that lists only one directory path of the command that the shell will run when the user issues the command from the shell prompt. For Example: which cp
5
passwd A user can change their account password by issuing passwd command at shell prompt. The user will be prompted for their current password and then be prompted for new password and confirmation. Options: -f changes the user information that is stored in the /etc/passwd file along with user's password
6
cal The cal command without options displays only the current month. The cal command with year as an argument displays the entire year's calendar. The cal command with arguments month followed by year displays the specific month for specific year. Examples: cal (displays all months for year 2002) cal (displays only month of September 1947)
7
date The date command is used to display the current date and time.
Example: date Note: If you have superuser or "root" access, you can change the computer system's date and time.
8
ps / kill As mentioned in last week’s notes, the Unix OS continually runs processes (jobs). The ps command is used to provide status information regarding processes such as PID (process I.D. number). The kill command can be used to terminate process number (eg. kill [PID] or kill –9 [PID]) Options: -l Provides detailed process status info (eg parent PID) -a Provides process status info for entire system -al Provides detailed info for all processes
9
Working with Files file, touch, cat, more, less grep, head, tail
cp, mv, ls sort, uniq, diff
10
file The file command is used to identify a type of file (for example, whether the file is an ASCII (text), executable file, graphics file, MS- PowerPoint file, a directory file, etc...). This command is useful if file does not contain an extension and therefore is hard to identify. Example: file try_me (Identifies the file type of "try_me")
11
touch The touch command is used to create empty files. This command is useful to create empty files to be edited later with content. Another use for this command is to create empty files in order to practise using Unix commands that may require a filename such as ls, cp, mv, etc… Example: touch file1 file2 file3 (Creates 3 files in current directory)
12
cat The cat command is used to combine the contents of multiple files (“catenate” means to join together). This command can be used to display contents of small files (that will fit on your terminal's display screen). Example: cat hello.c (displays contents of c program "hello.c")
13
more The more command displays a file, one screenful at a time.
Example: more large_file Movement keys (within more command): <spacebar> Move to next screen b Move to previous screen <enter> Move to next line /car Search for pattern "car" q Exit to shell
14
less The less command is similar to more command, but "less" command contains more movement and search commands than "more" command. Example less large_file Note: You are not required to learn "less" command for this course, but if you are interested in using this command, you can refer to online manual.
15
grep The grep command is used to search for a pattern whether contained in files or from other forms of input (eg. keyboard). Example: grep "frog" data (matches lines in file called "data" that contain pattern "frog") Options: -c displays # of lines that contain a match -i ignores case sensitivity -v displays lines that do not match the pattern
16
head The head command displays the beginning lines of a file. This command is useful to identify any heading information of a file. example: head fname (displays the first 10 lines of "fname") Options: -n displays the first "n" number of lines
17
tail The tail command displays the ending lines of a file. This command is useful for viewing files that continually add information to the bottom of a file such as log files (eg. Last person to logon, or last system message). Example: tail fname (views the last 10 lines of "fname") Options: -n displays the last "n" number of lines +n displays all lines from line "n" to the end of the file
18
cp The cp command is used to copy one or more files between directories, or to make backup copies of files within the same directory. Example: cp /public/ipc144/hw.c /home/msaul/ (copies file "hw.c" from “/public/ipc144" directory to msaul's home directory) Options: -R subdirectories & contents are copied -i prompts user to overwrite existing file
19
mv The mv command is used to move or rename files. Examples:
mv hw.c work (moves file "hw.c" from current directory to subdirectory called "work”, assuming directory “work” exists) mv hw.c hello.c (renames file "hw.c" in current directory to "hello.c”) Options: -i prompts user to overwrite existing file
20
ls The ls command is used to display information regarding a file or directory. Example: ls (Displays a compact listing (i.e. filenames only) contained in current directory) Options: -a short display of all files (incl. hidden files) -l detailed display of files (excl. hidden files) -al detailed display of all files -F displays / after directory, * after executable file
21
sort The sort command is used to sort or merge files. Particularly useful as a filter to sort standard input. Example: sort fname (alphabetically sorts (in ascending order) the contents of "fname") Options: -r sorts in reverse (descending order) -n sort numerically -kn Sorts by column number "n" -u sorts and only displays unique lines
22
uniq The uniq command is used to display lines from a file that are unique. Used after a sort, uniq will only display unique lines of text Example: uniq fname (Displays unique lines from file "fname“, eliminating duplicate adjacent lines)
23
diff Example: diff file1 file2
The diff command displays the differences between two files. If there are no differences in the files, there is no display. If there is a display the command provides instructions on how to make the first file identical to second file. Example: diff file1 file2
24
Communicating with Others
who finger talk write mesg
25
who Used to display names of users logged into system. Example: who
Options: -H displays headings above user information -i displays # of minutes user was idle -T displays message reception status
26
finger Used to display user names and related information. Example:
finger jsmith (Will provide information regarding user "jsmith") Options: -l displays detailed information of all users
27
talk / write talk allows user to conduct a two-way text-based conversation. To initiate talk you type: talk phobos_user_id (use who -T to determine if user is receiving messages) write is used to send a message to another user. To send a message, type: write phobos_user_id (Mainly used to broadcast a message but can be used to chat - use who -T to check mesg status first) NOTE: The talk command may be disabled for the Phobos and Matrix servers..
28
mesg Used to “turn on” or “turn off” reception of messages from other users. To turn on message reception status, type: mesg y <ENTER> To turn off message reception status, type: mesg n <ENTER>
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.