0% found this document useful (0 votes)
9 views24 pages

CHP 6 Commands 1

This document provides a comprehensive list of basic Ubuntu Linux commands along with their explanations. It covers commands for displaying system information, managing files and directories, performing calculations, and manipulating text. Additionally, it includes details on file permissions and command usage for various tasks.

Uploaded by

gjpain69
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views24 pages

CHP 6 Commands 1

This document provides a comprehensive list of basic Ubuntu Linux commands along with their explanations. It covers commands for displaying system information, managing files and directories, performing calculations, and manipulating text. Additionally, it includes details on file permissions and command usage for various tasks.

Uploaded by

gjpain69
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 24

Chp-6 Basic Ubuntu Linux Commands

No. Commands Explanation


1 cat /etc/shells It will display list of
all available shells in
the system.
2 echo $SHELL It will display default
shell in the system.
3 echo AG HIGH SCHOOL It will display the
message AG HIGH
SCHOOL.
4 echo My Name is ____ It will display the
message My Name is
____
5 clear It will clear the
screen.
6 exit We will exit the
screen.
7 ctrl+d It will exit the
screen.
8 cal It will display current
month’s calendar.
9 cal 08 2012 It will display August month
calendar of year 2012.
10 cal 12 2025 It will display December
month calendar of year
2025.
11 cal 2016 It will display entire year’s
calendar of year 2016.
12 cal 2020 It will display entire year’s
calendar of year 2020.
13 cal 05 2022 It will display May month
calendar of year 2022.
14 date It will display day, date,
month and time.
15 date +%d It will display current date as
its output. For example 4th
October 2021, answer will be
4th.
16 date +%m It will display month that is
10(October)
17 date +%y It will display last two digit
of year that is (21)
18 date +%Y It will display all 4 digit of
year that is 2021.
19 date +%H It will display current Hour.
20 date +%M It will display current
Minutes.
21 date +%S It will display current
Seconds.
22 date +%D It will display date in
mm/dd/yy format.
23 date +%T It will display time in
HH:MM:SS format.
24 date +%B It will display current month
that is (October).
25 date +%b It will display first 3
character of current month
that is (Oct).
26 date +%a It will display first 3
character of current day that
is (Mon).
27 date +%A It will display current day
that is (Monday).
28 bc -l Command line calculator
12*4
sqrt(40)
sqrt(9)
sqrt(729)-Square root.
l(2000)-natural logarithm.
99+2987
550-450
650*8975
29 In command line calculator the default input
base and output base is decimal where it is
written as ibase=10 and obase=10. The other
base for command line calculator are
decimal-10, binary-2, octal-8,hexadecimal-16

30 Convert 14×2 to hexadecimal number?


ibase=10
obase=16
14×2
Ans:-
31 Convert 15×2 to binary number?
ibase=10
obase=2
15×2
Ans:-
32 Convert binary number 11101 to decimal
number?
ibase=2
obase=10
11101
Ans:-
33 Convert 11110 to octal number?
ibase=2
obase=8
11110
Ans:-
34 Convert octal number 36 to binary number?
ibase=8
obase=2
36
Ans:-
35 Convert hexadecimal number 1002 to binary
number?
ibase=16
obase=2
1002
Ans:-
36 Convert binary number 11101 to
hexadecimal number?
ibase=2
obase=16
11101
Ans:-
37 echo “Hi how r u?” Hi How r u? message
It is a back will be printed.
quote that
is given 38 echo“Current time is Current time is
below Esc
key. `date +”%T”`” 11:30:25 will be
displayed.
39 who It will display all login-
id’s.
40 who am i Out of all login-id’s
our login-id will be
displayed.
41 echo $HOME Home directory will be
displayed.
42 pwd Present Working
Directory will be
displayed.
43 mkdir Make directory
44 cd Change directory
45 cd .. To come out of a
directory
46 mkdir temp temp directory will be
created.
47 ls List of files and
directory.
48 mkdir birds birds directory will be
created.
49 ls List of files and
directory.

50 mkdir fruits Fruits directory will be


created.
51 ls List of files and
directory.
52 cd fruits To go inside fruits
directory.
53 mkdir apple mango Two directories
named apple and
mango will be created.
54 ls List of files and
directory.
55 cd apple To go inside apple
directory.
56 mkdir red green Two directories
named red and green
will be created.
57 cd .. To come out of apple
file.
58 cd .. To come out of fruits
file.

59 mkdir earth Earth directory will be


created.
60 cd earth To go inside earth
directory.
61 ls List of files and
directory.
62 mkdir India Srilanka India, Srilanka and
Nepal Nepal directory will be
created.
63 cd India To go inside India
directory.
64 ls List of files and
directory.
65 mkdir Gujarat UP MP Gujarat UP and MP
directory will be
created.
66 cd .. To come out of India
directory.
67 cd .. To come out of earth
directory.
68 ls -R To view
subdirectories.
69 ls -l To view long list of
files and directories.
70 ls -a To view hidden files
and directories.
71 ls -X To view list of files
with columns.
72 cat>filename To create file
73 cat filename To view content of file
74 cat>>filename To append file that
means to add content
to file already created.
75 cat>.filename To create hidden file.

76 cat file1 file2>file3 To concate that is join


files together.
77 cat>Ahmedabad Ahmedabad file will
It is a metro city. be created.

[ctrl+d] press( To
come out of file)
78 cat Ahmedabad Can view content of
file.
79 cat>>Ahmedabad Good morning will be
Good morning. added to file.

[ctrl+d] press( To
come out of file)
80 cat Ahmedabad Can view content of
file.
81 ls List of files and
directory.
82 cat>school
Ag High School. To create school file.
Navrangpura.
[ctrl+d] press( To
come out of file)
83 cat school Can view content of
file.
84 ls List of files and
directory.
85 cp school college Copy content of
school file to college
file.
86 mv school highschool Rename school file to
highschool file.
87 ls List of files and
directory.
88 cat>mumbai Mumbai file will be
It is a metro city. created.

[ctrl+d] to come out


of file.
89 rm mumbai To remove file
mumbai.
90 ls List of files and
directory.
91 mkdir one two Creates directory
named one and two.
92 rmdir one Removes directory
one
93 ls List of files and
directory.
94 wc-Word Counter
wc –l filename=Counts number of lines in a
file.
wc –w filename=Counts number of words in
a file.
wc –c filename=Counts number of characters
in a file.
wc –lwc filename=Counts number of lines,
words and characters in a file.
95 wc –l highschool Counts number of lines
in highschool file.
96 wc –w highschool Counts number of
words in highschool
file.
97 wc –c highschool Counts number of
character in highschool
file.
98 wc –lwc highschool Counts number of
lines, words and
characetrs in
highschool file.
99 File Permission:-
A hyphen in any position means that you
don’t have that particular permission.
The character hyphen(-) stands for file.
The character d stands for directory.
r-read, w-write, x-execute are the three
permission which can be given to ugo
that is user, group and others.
1)user-read, write and execute
2)group-read, write and execute
3)other-read, write and execute
100 ls –l filename To check permissions
of given file.
101 ls –l highschool To check permissions
of highschool file
102 To give permission to files we use change
mode command which is written as chmod.
+ is used to give permission.
- is used to take back permission.
103 cat>bat Bat file is created.
this is a bat file.
[ctrl+d] to come out
of file.
104 ls –l bat To check permission on
bat file.
105 chmod g+x bat To give execute
permission to group on
bat file.
106 chmod o+w bat To give write
permission to others
on bat file.
105 ls –l bat To check whether
permissions are given
or not.
105 chmod g-x bat To take back execute
permission from group
on bat file.
106 chmod o-w bat To take back write
permission from others
on bat file.
107 ls –l bat To check whether
permissions are taken
back or not.
108 chmod ugo-w bat To take write
permission from
user,group and others
on bat file.
109 ls –l bat To check whether
permissions are taken
back or not.
110 chmod ugo+x bat To give execute
permission to
user,group and others
on bat file.
111 ls –l bat To check whether
permissions are given
or not.
112 To compress file gzip command is used and
to decompress a file gunzip command is
used.
113 wc –c highschool To check size of file.
114 gzip highschool To compress file.
115 gunzip highschool.gz To decompress a file.
or
gzip –d highschool.gz
116 wc –c highschool To check size of file.
117 ls>list Ls output will be
redirected to list file.
118 cat list To view content of
file.
119 ls | wc –l Ls output will become
input to wc command
and pipe symbol is
used to connect
commands together.
120 cat>city City file is created
a’bad
baroda
surat
rajkot
mumbai
[ctrl+d] to come out
of file
121 head -3 city First 3 city names will
be displayed.
122 tail -3 city Last 3 city names will
be displayed.
123 tail –n+4 From 4th city all city
names will be
displayed.
124 cat>student
101: Rita Mehta : Commerce
102: Gita Patel : Science
103: Hema Shah : Commerce
104: Riya Jain : Commerece
105: Sita Dave :Science
125 cut –d “ :” –f 3 student 3rd column will be
extracted from
student file.
126 cut –d “ :” –f 1 student 1st column will be
extracted from
student file.
127 cut –d “ :” –f 2-3 student Range 2-3 will be
extracted from
student file.
128 cut –d “ :” –f 1,3 student 1st and 3rd column
will be extracted
from student file.
129 cut –d “ :” –f 3 student>field
130 cut –d “ :” –f 2 student>name
131 paste field name Both above files
will be pasted
together .
132 sort –r student Student file will be
sorted in reverse
order.
133 cat student | tr ‘[a-z]’ All lower case letter
‘[A-Z]’ will be converted to
upper case letters.
134 cat>stu Stu file will be
hi how r u ? created .

[ctrl+d]
135 tr –s ‘ ’<stu All extra space will
be squeezed from
stu file.
136 grep: searching for a pattern.
It means search globally for a regular
expression and display lines where instances
are found.
137 grep “Gita” student From student file
gita’s record will be
displayed.
138 grep “science” student From student file
science student
records will be
displayed.
139 grep –v “sita” student From student file
except sita other
records will be
displayed.
140 grep –ic “Commerce” From student file
student all commerce
students record will
be counted and
displayed.

You might also like