Command Ex-2003
Command Ex-2003
Calendar
cal cal - Would give you the calendar for this month.
cal 12 2000 - Would give you the calendar for December of 2000.
vi myfile.txt
Edits the file myfile.txt.
vi
Esc:q!
Typing the above command would exit the vi edit done with the above
command.
View a file.
cat
Cat file1.txt. Reads file1.txt
C compiler.
cc
cc myfile.c - would compile the file myfile.c.
Change directory.
cd cd ../home/users/computerhope
cd
Compare files.
cmp cmp file1.txt file2.txt - Compares file1 to file2 and outputs results. Below is
example of how these results may look.
file.txt file2.txt differ: char 1011, line 112
Copy files.
cp
cp file1.txt file2.txt
Copies the file1.txt in the file2.txt in current directory.
exit Exit from a program, shell or log you out of a Unix network.
Finds one or more files assuming that you know their approximate filenames.
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
grep for lines of text that match one or many regular expressions, and outputs only
the matching lines.
In the above example this command would list each of the files in the current
directory and the files permissions, the size of the file, date of the last
modification, and the file name or directory. Below is additional information
about each of the fields this command lists.
ls -l
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
Display a manual of a command.
man
man mkdir - Lists help information on the mkdir command.
Create a directory.
mkdir
mkdir mydir - This would create a new directory called mydir.
Typing ps alone would list the current running processes. Below is an example
of the output that would be generated by the ps command.
ps Where PID is process id, TTY is terminal that is process attach to, CMD is
command that is running
PID TTY TIME CMD
6874 pts/9 0:00 ksh
6877 pts/9 0:01 csh
418 pts/9 0:00 csh
ps -ef
Display full information about each of the processes currently running.
UID PID PPID C STIME TTY TIME CMD
hope 29197 18961 0 Sep27 ? 00:00:06 sshd: hope@pts/87
hope 32097 29197 0 Sep27 pts/87 00:00:00 -csh
hope 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 below
example.
rm myfile.txt
rm
Remove the file myfile.txt without prompting the user.
rm -r directory
Remove a directory, even if files existed in that directory.
Displays a count of lines, words, and characters in a file
wc wc myfile.txt
Sort command sort the lines of a file or files, in alphabetical order. for
example if you have a file named testfile with these contents
zzz
aaa
1234
yuer
wer
Sort qww
wwe
Then running sort testfile will give us output of
1234
aaa
qww
wer
wwe
yuer
zzz