[go: up one dir, main page]

0% found this document useful (0 votes)
59 views4 pages

Command Ex-2003

The document provides summaries of common Linux commands including their usage and purpose. It covers commands for calculations, calendars, text editors, compilers, file manipulation, process management and more. Each command summary includes its name, basic usage examples, and a brief description of what the command does.

Uploaded by

Harshil Shah
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
59 views4 pages

Command Ex-2003

The document provides summaries of common Linux commands including their usage and purpose. It covers commands for calculations, calendars, text editors, compilers, file manipulation, process management and more. Each command summary includes its name, basic usage examples, and a brief description of what the command does.

Uploaded by

Harshil Shah
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Calculator.

bc cal.txt = Would result in 3, see below notes.


bc
sqrt ( E ), length ( E ), scale ( E )

Quit : Exits the bc command.

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

clear Clears screen.

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.

date Tells you the date and time in Unix.

Displays text after echo to the terminal.


echo
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.

Finds one or more files assuming that you know their approximate filenames.

find find -name 'mypage.htm'


In the above command the system would search for any file named
mypage.htm in the current directory and any subdirectory.

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.

grep 'word' filename

ls Lists the contents of a directory.

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.

Reports the process status.

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.

pwd Print the current working directory.

Deletes a file without confirmation (by default).

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

5    13    57   myfile.txt 5 = Lines,13 = Words,57 = Characters

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

You might also like