Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Linux Basic Commands: Functionality and Syntax, Exercises of Computer Fundamentals

An overview of essential linux commands, their syntax, and functionality. It covers topics such as listing files, changing directories, creating and removing files and directories, managing permissions, and installing rpm packages. This information is useful for university students and lifelong learners who want to gain a solid understanding of linux systems.

Typology: Exercises

2011/2012

Uploaded on 07/31/2012

karthik
karthik 🇮🇳

4.6

(16)

95 documents

1 / 5

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Basic Commands
1.ls -l for listing the files as well as directories those are kept in
the particular working directory
syntax
[root@nettech root]#ls -l
2.ls -la same as 'ls -l'but by this command we can also see the hiden
files.
syntax
[root@nettech root]#ls -la
3.ls -li same as 'ls -la' but it will also shows us the inode number of
each and every file
syntax
[root@nettech root]#ls -li
4.ls by this command we can see only file name nothing else
syntax
[root@nettech root]#ls
5.clear it will clear the screen(short cut ctl+l)
syntax
[root@nettech root]#clear
6.exit to end a current session as well current terminal logging
syntax
[root@nettech root]exit
7.touch to create a new empty file
syntax
[root@nettech root]#touch
8.cd to change the working/present directory
syntax
[root@nettech root]#cd /home/mango
where '/home/mango' is the desired directory to be change from
'/root'
9.cat to view the contents of a file and it is also used for creating a
new file with some contents
syntax
[root@nettech root]#cat <file name> to view file contents
[root@nettech root]#cat > newfilename enter,then you can write something in
the file and then to save the file contents press clt+d then enter
10.mkdir to make a new directory
syntax
[root@nettech root]#mkdir newdirname
you can also create a directory at your desired path without
changing your present working directory
syntax
[root@nettech root]#mkdir /home/mango/newdirname
11.rm to remove a empty file
syntax
[root@nettech root]#rm filename
Page 1
docsity.com
pf3
pf4
pf5

Partial preview of the text

Download Linux Basic Commands: Functionality and Syntax and more Exercises Computer Fundamentals in PDF only on Docsity!

1.ls -l for listing the files as well as directories those are kept in the particular working directory syntax [root@nettech root]#ls -l

2.ls -la same as 'ls -l'but by this command we can also see the hiden files. syntax [root@nettech root]#ls -la

3.ls -li same as 'ls -la' but it will also shows us the inode number of each and every file syntax [root@nettech root]#ls -li

4.ls by this command we can see only file name nothing else syntax [root@nettech root]#ls

5.clear it will clear the screen(short cut ctl+l) syntax [root@nettech root]#clear

6.exit to end a current session as well current terminal logging syntax [root@nettech root]exit

7.touch to create a new empty file syntax [root@nettech root]#touch

8.cd to change the working/present directory syntax [root@nettech root]#cd /home/mango where '/home/mango' is the desired directory to be change from '/root'

9.cat to view the contents of a file and it is also used for creating a new file with some contents syntax [root@nettech root]#cat to view file contents [root@nettech root]#cat > newfilename enter,then you can write something in the file and then to save the file contents press clt+d then enter

10.mkdir to make a new directory syntax [root@nettech root]#mkdir newdirname you can also create a directory at your desired path without changing your present working directory syntax [root@nettech root]#mkdir /home/mango/newdirname

11.rm to remove a empty file syntax [root@nettech root]#rm filename

Page 1

12.rmdir to remove a empty directory syntax [root@nettech root]#rmdir directoryname

13.rm [-i/-r/-f] to remove a directory with its subdirectories as well as its files that is to remove a directory which already contains some files in it syntax [root@nettech root]#rm -i directory/filename -i stands for interactively -r stands for recursively -f stands for forcefully 14.cp to copy something in a destination file or directory syntax [root@nettech root]#cp sourcepath destinationpath example: [root@nettech root]#cp /home/mango/webmin.rpm /root/abcd in this example the webmin.rpm file will be copied in /root/abcd directory

15.mv to move one file or directory from one place to another place, it is also used for renaming adirectory or file syntax [root@nettech root]#mv source destination [root@nettech root]#mv oldfilename newfilename [to change the file name]

16.man to view the mannual page of commands for syntax syntax [root@nettech root]#man commandname

17.info to view the information about any command syntax [root@nettech root]#mkdir info

18.--help to view the help doccuments of a command syntax [root@nettech root]#commandname --help

19.dir to view the subdirectories and filesn under the directory syntax [root@nettech root]#dir

20.su - to become a super user syntax [mango@nettech mango]$su - output wil be [root@nettech root#]

21.who by this command you can see the user name and their ip addresses who have loged in on your server syntax [root@nettech root]#who

22.whoami this command shows your current logged in terminal user name syntax [root@nettech root]#whoami

23.who am i this command shows you the logged in terminal number and user name and more detailed information Page 2

34.groupadd to add a new group syntax [root@nettech root]#groupadd groupname

35.gruopdel to delete a group syntax [root@nettech root]#groupdel groupname

36.chown to change the ownership of a file or directory syntax [root@nettech root]#chown ownername filename example: [root@nettech /]#ls -l output drwxrw-rw- 2 root root 4096 Mar 11 12:03 abcd (permission) (own) (group own)(size) (name)

[root@nettech root]#chown tarun /abcd in this example /abcd directory owner will be change to tarun user effect [root@nettech /]#ls -l drwxrw-rw- 2 tarun root 4096 Mar 11 12:03 abcd

37.chgrp to change the group ownership of a file or directory syntax [root@nettec root]#chgrp newgroupownername filename example [root@nettech /]#ls -l drwxrw-rw- 2 tarun root 4096 Mar 11 12:03 abcd [root@nettech root]#chgrp tarun /abcd effect [root@nettech /]#ls -l drwxrw-rw- 2 tarun tarun 4096 Mar 11 12:03 abcd

38.chmod to change the permission of a file or directory drwxrw-rw- 2 root root 4096 Mar 11 12:03 abcd (permission) (ownr) (grpownr) (size) (name) IN OCTAL VALUE d stands for directiry READ= r stands for read only permission WRITE= w stands for write only permission EXECUTE= x stands for execute only permission drwxrw-rw- FIRST OCTET FOR DENOTING THE DIRECTORY OR FILE OR LINK FILE ETC. SECOND THREE OCTET FOR USER OR OWNER PERMISSION (rwx OR 7 IN OCTAL VALUE) THIRD THREE OCTET FOR GROUP PERMISSION (rw- OR 6 IN OCTAL VALUE)

FORTH THREE OCTET FOR OTHERS PERMISSION (rw- OR 6 IN OCTAL VALUE) SYNTAX [root@nettec root]#chmod value fileordirectoryname example

[root@nettech /]#ls -l drwxrw-rw- 2 tarun root 4096 Mar 11 12:03 abcd [root@nettech /]#chmod 402 /abcd [root@nettech /]#ls -l drw-----w- 2 tarun tarun 4096 Mar 11 12:03 abcd

40.usermod to modify the user profile Page 4

synatx [root@nettech root]#usermod -parameter groupname username

Page 5