command.ex-2003.doc
Post on 08-Apr-2018
218 Views
Preview:
TRANSCRIPT
-
8/7/2019 command.ex-2003.doc
1/4
bc
Calculator.
bc cal.txt = Would result in 3, see below notes.
sqrt ( E ), length ( E ), scale ( E )
Quit : Exits the bc command.
cal
Calendar
cal - Would give you the calendar for this month.
cal 12 2000 - Would give you the calendar for December of 2000.
vi
vi myfile.txt
Edits the file myfile.txt.Esc:q!
Typing the above command would exit the vi edit done with the abovecommand.
catView a file.
Cat file1.txt. Reads file1.txt
ccC compiler.
cc myfile.c - would compile the file myfile.c.
cd
Change directory.
cd ../home/users/computerhope
cd
clear Clears screen.
cmp
Compare files.
cmp file1.txt file2.txt - Compares file1 to file2 and outputs results. Below isexample of how these results may look.
file.txt file2.txt differ: char 1011, line 112
http://www.google.com/url?q=http%3A%2F%2Fwww.computerhope.com%2Funix%2Fubc.htm&sa=D&sntz=1&usg=AFQjCNEjqd3SqHy0epiq8eN15zyvoZi3xwhttp://www.google.com/url?q=http%3A%2F%2Fwww.computerhope.com%2Funix%2Fucal.htm&sa=D&sntz=1&usg=AFQjCNGOI9lSL2tupSRQty5AhB2UNjnQsAhttp://www.google.com/url?q=http%3A%2F%2Fwww.computerhope.com%2Funix%2Fuvi.htm&sa=D&sntz=1&usg=AFQjCNE2IrKDX0CD_C4lD6ZE7q4u6WePmQhttp://www.google.com/url?q=http%3A%2F%2Fwww.computerhope.com%2Funix%2Fucat.htm&sa=D&sntz=1&usg=AFQjCNF9oZplFOcEQSk-cA5sG4cWxJD27Ahttp://www.google.com/url?q=http%3A%2F%2Fwww.computerhope.com%2Funix%2Fucc.htm&sa=D&sntz=1&usg=AFQjCNGPENfLwsHnEkpHcqzZtSoRgFzeZQhttp://www.google.com/url?q=http%3A%2F%2Fwww.computerhope.com%2Funix%2Fucd.htm&sa=D&sntz=1&usg=AFQjCNHJ7uW1HfdQjIF_vxuET4e7nGGrNwhttp://www.google.com/url?q=http%3A%2F%2Fwww.computerhope.com%2Funix%2Fuclear.htm&sa=D&sntz=1&usg=AFQjCNEthC5MGbBoUQb156Fl0XA0Nqe3zghttp://www.google.com/url?q=http%3A%2F%2Fwww.computerhope.com%2Funix%2Fucmp.htm&sa=D&sntz=1&usg=AFQjCNHLXS2o5K9darSlCp6kfUzyApphUghttp://www.google.com/url?q=http%3A%2F%2Fwww.computerhope.com%2Funix%2Fucmp.htm&sa=D&sntz=1&usg=AFQjCNHLXS2o5K9darSlCp6kfUzyApphUghttp://www.google.com/url?q=http%3A%2F%2Fwww.computerhope.com%2Funix%2Fuclear.htm&sa=D&sntz=1&usg=AFQjCNEthC5MGbBoUQb156Fl0XA0Nqe3zghttp://www.google.com/url?q=http%3A%2F%2Fwww.computerhope.com%2Funix%2Fucd.htm&sa=D&sntz=1&usg=AFQjCNHJ7uW1HfdQjIF_vxuET4e7nGGrNwhttp://www.google.com/url?q=http%3A%2F%2Fwww.computerhope.com%2Funix%2Fucc.htm&sa=D&sntz=1&usg=AFQjCNGPENfLwsHnEkpHcqzZtSoRgFzeZQhttp://www.google.com/url?q=http%3A%2F%2Fwww.computerhope.com%2Funix%2Fucat.htm&sa=D&sntz=1&usg=AFQjCNF9oZplFOcEQSk-cA5sG4cWxJD27Ahttp://www.google.com/url?q=http%3A%2F%2Fwww.computerhope.com%2Funix%2Fuvi.htm&sa=D&sntz=1&usg=AFQjCNE2IrKDX0CD_C4lD6ZE7q4u6WePmQhttp://www.google.com/url?q=http%3A%2F%2Fwww.computerhope.com%2Funix%2Fucal.htm&sa=D&sntz=1&usg=AFQjCNGOI9lSL2tupSRQty5AhB2UNjnQsAhttp://www.google.com/url?q=http%3A%2F%2Fwww.computerhope.com%2Funix%2Fubc.htm&sa=D&sntz=1&usg=AFQjCNEjqd3SqHy0epiq8eN15zyvoZi3xw -
8/7/2019 command.ex-2003.doc
2/4
cp
Copy files.
cp file1.txt file2.txt
Copies the file1.txt in the file2.txt in current directory.
date Tells you the date and time in Unix.
echo
Displays text after echo to the terminal.
echo Hello world
The above example would return "Hello world" to the console
exit Exit from a program, shell or log you out of a Unix network.
find
Finds one or more files assuming that you know their approximate filenames.
find -name 'mypage.htm'
In the above command the system would search for any file namedmypage.htm in the current directory and any subdirectory.
grep
grep command searches the given file for lines containing a match to the given
strings or words. By default, grep prints the matching lines. Use grep to search
for lines of text that match one or many regular expressions, and outputs only
the matching lines.
grep 'word' filename
ls Lists the contents of a directory.
ls -l
In the above example this command would list each of the files in the currentdirectory and the files permissions, the size of the file, date of the lastmodification, and the file name or directory. Below is additional informationabout each of the fields this command lists.
Permissions Directories Group Size Date Directory or file
drwx------ 2 users 4096 Nov 2 19:51 mail/
drwxr-s--- 35 www 32768 Jan 20 22:39 public_html/
-rw------- 1 users 3 Nov 25 02:58 test.txt
http://www.google.com/url?q=http%3A%2F%2Fwww.computerhope.com%2Funix%2Fucp.htm&sa=D&sntz=1&usg=AFQjCNGy49OT8GS8WO-9jG8HaXBvOH17uQhttp://www.google.com/url?q=http%3A%2F%2Fwww.computerhope.com%2Funix%2Fudate.htm&sa=D&sntz=1&usg=AFQjCNGkzYXWrIUf_A-rQdEIR15I_7pZMAhttp://www.google.com/url?q=http%3A%2F%2Fwww.computerhope.com%2Funix%2Fuecho.htm&sa=D&sntz=1&usg=AFQjCNF_BoAwLaPX5fzvTNYthoUrwHKYCwhttp://www.google.com/url?q=http%3A%2F%2Fwww.computerhope.com%2Funix%2Fuexit.htm&sa=D&sntz=1&usg=AFQjCNFsEDDqD95HIQ-jcRTV2Q61187aTwhttp://www.google.com/url?q=http%3A%2F%2Fwww.computerhope.com%2Funix%2Fufind.htm&sa=D&sntz=1&usg=AFQjCNHrkdBepx6UYt7Viicv0KsGFJpjqghttp://www.google.com/url?q=http%3A%2F%2Fwww.computerhope.com%2Funix%2Fuls.htm&sa=D&sntz=1&usg=AFQjCNE9EwBawnBoQjaADiSh-u7dobMaVwhttp://www.google.com/url?q=http%3A%2F%2Fwww.computerhope.com%2Funix%2Fuls.htm&sa=D&sntz=1&usg=AFQjCNE9EwBawnBoQjaADiSh-u7dobMaVwhttp://www.google.com/url?q=http%3A%2F%2Fwww.computerhope.com%2Funix%2Fufind.htm&sa=D&sntz=1&usg=AFQjCNHrkdBepx6UYt7Viicv0KsGFJpjqghttp://www.google.com/url?q=http%3A%2F%2Fwww.computerhope.com%2Funix%2Fuexit.htm&sa=D&sntz=1&usg=AFQjCNFsEDDqD95HIQ-jcRTV2Q61187aTwhttp://www.google.com/url?q=http%3A%2F%2Fwww.computerhope.com%2Funix%2Fuecho.htm&sa=D&sntz=1&usg=AFQjCNF_BoAwLaPX5fzvTNYthoUrwHKYCwhttp://www.google.com/url?q=http%3A%2F%2Fwww.computerhope.com%2Funix%2Fudate.htm&sa=D&sntz=1&usg=AFQjCNGkzYXWrIUf_A-rQdEIR15I_7pZMAhttp://www.google.com/url?q=http%3A%2F%2Fwww.computerhope.com%2Funix%2Fucp.htm&sa=D&sntz=1&usg=AFQjCNGy49OT8GS8WO-9jG8HaXBvOH17uQ -
8/7/2019 command.ex-2003.doc
3/4
manDisplay a manual of a command.
man mkdir - Lists help information on the mkdir command.
mkdir
Create a directory.
mkdir mydir - This would create a new directory called mydir.
ps
Reports the process status.
Typing ps alone would list the current running processes. Below is an exampleof the output that would be generated by the ps command.
Where PID is process id, TTY is terminal that is process attach to, CMD iscommand that is running
PID TTY TIME CMD
6874 pts/9 0:00 ksh6877 pts/9 0:01 csh418 pts/9 0:00 csh
ps -ef
Display full information about each of the processes currently running.
UID PID PPID C STIME TTY TIME CMDhope 29197 18961 0 Sep27 ? 00:00:06 sshd: hope@pts/87hope 32097 29197 0 Sep27 pts/87 00:00:00 -cshhope 7209 32097 0 12:17 pts/87 00:00:00 ps -ef
ps -l
Displays processes including those that are in a wait state, similar to the belowexample.
pwd Print the current working directory.
rm
Deletes a file without confirmation (by default).
rm myfile.txt
Remove the file myfile.txt without prompting the user.
rm -r directory
Remove a directory, even if files existed in that directory.
http://www.google.com/url?q=http%3A%2F%2Fwww.computerhope.com%2Funix%2Fuman.htm&sa=D&sntz=1&usg=AFQjCNHZTpK0k8gPiLM0qE5cR5BXpqFMJwhttp://www.google.com/url?q=http%3A%2F%2Fwww.computerhope.com%2Funix%2Fumkdir.htm&sa=D&sntz=1&usg=AFQjCNFF5YgLKyGn-3le6TNkEFO8VmceTwhttp://www.google.com/url?q=http%3A%2F%2Fwww.computerhope.com%2Funix%2Fups.htm&sa=D&sntz=1&usg=AFQjCNFe4zSE_11XJT8xx7QPKdJd2gh1Fghttp://www.google.com/url?q=http%3A%2F%2Fwww.computerhope.com%2Funix%2Fupwd.htm&sa=D&sntz=1&usg=AFQjCNFo0zwdHTywA8clmGX5Dneqiok2cQhttp://www.google.com/url?q=http%3A%2F%2Fwww.computerhope.com%2Funix%2Furm.htm&sa=D&sntz=1&usg=AFQjCNEHpXYeWYTEDre_b6bW26w1Ep-9Mwhttp://www.google.com/url?q=http%3A%2F%2Fwww.computerhope.com%2Funix%2Furm.htm&sa=D&sntz=1&usg=AFQjCNEHpXYeWYTEDre_b6bW26w1Ep-9Mwhttp://www.google.com/url?q=http%3A%2F%2Fwww.computerhope.com%2Funix%2Fupwd.htm&sa=D&sntz=1&usg=AFQjCNFo0zwdHTywA8clmGX5Dneqiok2cQhttp://www.google.com/url?q=http%3A%2F%2Fwww.computerhope.com%2Funix%2Fups.htm&sa=D&sntz=1&usg=AFQjCNFe4zSE_11XJT8xx7QPKdJd2gh1Fghttp://www.google.com/url?q=http%3A%2F%2Fwww.computerhope.com%2Funix%2Fumkdir.htm&sa=D&sntz=1&usg=AFQjCNFF5YgLKyGn-3le6TNkEFO8VmceTwhttp://www.google.com/url?q=http%3A%2F%2Fwww.computerhope.com%2Funix%2Fuman.htm&sa=D&sntz=1&usg=AFQjCNHZTpK0k8gPiLM0qE5cR5BXpqFMJw -
8/7/2019 command.ex-2003.doc
4/4
wc
Displays a count of lines, words, and characters in a file
wc myfile.txt
5 13 57 myfile.txt 5 = Lines,13 = Words,57 = Characters
Sort
Sort command sort the lines of a file or files, in alphabetical order. forexample if you have a file named testfile with these contents
zzzaaa1234yuerwerqwwwweThen running sort testfile will give us output of
1234aaaqwwwerwweyuerzzz
http://www.google.com/url?q=http%3A%2F%2Fwww.computerhope.com%2Funix%2Fuwc.htm&sa=D&sntz=1&usg=AFQjCNFDWUs-7iEd6DzJ2qE1x6u6O-inzAhttp://www.google.com/url?q=http%3A%2F%2Fwww.computerhope.com%2Funix%2Fuwc.htm&sa=D&sntz=1&usg=AFQjCNFDWUs-7iEd6DzJ2qE1x6u6O-inzA
top related