Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
32 views

Lecture 7 - 14 Commands

The document covers various Linux commands like touch, mkdir, cat, head, tail, echo, rm, cp, and mv. It provides examples and explanations of how to use each command including creating, reading, updating, copying, moving and deleting files and folders.

Uploaded by

Akash
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
32 views

Lecture 7 - 14 Commands

The document covers various Linux commands like touch, mkdir, cat, head, tail, echo, rm, cp, and mv. It provides examples and explanations of how to use each command including creating, reading, updating, copying, moving and deleting files and folders.

Uploaded by

Akash
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 5

------------------- Lecture 7 ---------------------------------

# touch ----> update time system any file or make files

1. touch india.txt
touch a1.txt a2.txt a3.txt

# with location--->
1. touch /tmp/india.txt

# make multiplues files --->


touch abs{1..10}

# see stat time ---> stat india.txt ( syntax--> stat fileName)


# see date ---> date

# for update india.txt file time update --> touch india.txt

///// touch --help /////

===================================================================================
===========

------------------- lecture 8 ----------------------------------

# mkdir ---> create folder/Directory


1. mkdir akash
2. mkdir /home/akash/india
3. mkdir b1 b2 b3 b4 b5
4. mkdir abc{1..10}
5. mkdir .mydir
6. mkdir old new
7. mkdir old/ new
8. mkdir "sanjay dahiya"

///// mkdir --help /////

# mkdir -p laptop/desktop ( create two folders at a time for creating desktop


folder when laptop foldr is not exist)

------------------ lecture 9
---------------------------------------------------------------------

# cat ---> create file or read and write contant under file

cat
for write--->
# cat > myfile.txt
welcome to linux
hello india
welcome to aws cloud

////// for save -- after enter press ctrl + D //////////

for read--->
# cat myfile.txt
# for series---> cat -n myfile.txt

# put more contant in already exixt file ---> cat >> myfile.txt
hello kali linux
welcome azure cloud

# for reverse the lines ---> tac myfile.txt

# for read only file --- nl myfile.txt

# cat -n /etc/passwd or cat /etc/passwd

===================================================================================
=======

------------- lecture 10 ----------------------------------

# use of ; --> multipal commands execute in a single line or write more commands in
one line

# mdkir keyboard ; cd keyboard ; touch india ; ls

# use of | command ---> execute another command as a refrence of first command or


manipulate the commands

===================================================================================
=============

------------ lecture 11 -----------------------------------------

# head & Tail ----> read file

/// # head ---> show by default 10 lines of any folder from top to bottam ///

# head /etc/passwd ---> show top 10 lines of PASSWD file

# head /etc/passwd | nl ----> sjow top 10 lines in a series of PASSWD file


----or-----------------------
# head /etc/passwd | cat -n ----> " " " " " " " " " " " " " " " " " " " "

// for show more than 10 lines using head command ////

# head -n 15 /etc/passwd | cat -n ----> show top 15 lines


# head -n 6 /etc/passwd | cat -n ----> show top 6 lines

---------------------------------------------------------------------

/// # tail ---> show by default 10 lines of any folder from bottam to top ///

# tail -n 12 /etc/passwd | nl ---> show bottam 12 lines of PASSWD file

/// Ques - passwd folder has 30 lines. So print only line 20 to 26 lines of passwd
folder. ///
1. head -n 25 /etc/passwd | nl ---> show top 25 lines of PASSWD folder using head
command
2. head -n 25 /etc/passwd | nl | tail -n 5 ---> manipulating the first command by
using pipe command (|) and print last 5 bottam lines of first command
---------- proved -------------------------------------------------------

For continue read any log file ---> use -F

# tail -F /var/log/messages

===================================================================================
====================

--------------- lecture 12 ---------------------------------------------

# message printing ---> echo

# echo "welcome to india" ---> print this message


# echo "welcome to india" > sanjay.txt ---> save this message on sanjay.txt file if
exixt or not exixt

# echo "hello india" >> sanjay.txt ---> again print this message in sanjay.txt file

# head -n 25 /etc/passwd | nl | tail -n 5


# head -n 25 /etc/passwd | nl | tail -n 5 >> sanjay.txt

/// for clear the sanjay.txt file/// --->

# echo > sanjay.txt

///////////////// for read all files --> cat sanjay.txt /////////////////

===================================================================================
======================

-------------- lecture 13 ---------------------------------------------

# rm ---> delete file

# rm a1.txt ---> delete the file#


# rm b2 ---> show error (Not delete any foleder without options)
--->
# rm -r b2 ---> delete the folder b2

/// for force fully delete any folder ---->

# rm -f a2.txt ---> force fully delete


# rm -fr b4 ---> delete

/// show what delete--->


# rm -rv abc1 ---> delete

// delete Dir of file --->


# rm -rvf b5 a3.txt ---> delete dir or file
/// delete the data of tmp--->
# cd /tmp/
# rm -rvf * ---> "*" means all

# rm -rvf /tmp/* ---> delete all without going path

------------------>
# rename for file anf folder ---> rename { syntax --( old name new name old
name )}

example-->
1. mkdir india
2. rename india delhi india (old name new name old name)
3. ls

===================================================================================
===========

--------------- lecture 14 -----------------------------------------------

For copy ----> cp

# ls
# touch abc ---> make file
# mkdir india ---> make file
# ls
# cp abc india --> copy abc file in india folder
# ls india/
# cp delhi india ---> error ( without options dir not copy )
# cp -r delhi india
# ls india/

# touch abc{1..10}
# ls
# cp -rvf abc{} india
# ls india/

# touch abc{11..20}
# ls
# cp -rvf abc{11..20} india
# ls india/

# touch abc{21..30}
# ls
# cp -rvf abc{21..30} india OR cp -rvf abc* india ---> copy all files start with
abc but overwrite every time (y,y,y...)
# cp -rvfn abc* india ---> "n" for no overwrite

# cd /etc
# ls
# cp -rvf * /root/india/
# ls
# cd india
# ls
-------------------------------------------------------------------

# for move ---> mv

# mv delhi india/ ---> overwrite


# y
# ls
# cd india/

===================================================================================
==

You might also like