Basic Commands in Linux

You might also like

Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 3

basic commands in linux

1.creating file(empty file)


cat= concatenant
syntax= cat > filename
hi pradeep
hello world
you have to learn well pradeep this aws ==this is all data for new creating file
after giving data to our created file

we have to save that file


2.saving created file
ctrl+d = to save a created file and exit

3.opening created file


syntax = cat filename
eg = cat VP (cat = command vp = filename)

4.if we want add or append more date to existed file or already created file
syntax = cat >> <existing file name>
eg= cat >> VP
here we have space to write anything

5.if we want create multiple files <touch file1 file2> like this
if we want give range to files we have to give filename with range = touch
file{1..50}
we have to use only flower brackets to give file range .

6.removing file
syntax = rm filename
we can also give range for deleting multiple files at time.
ex.rm f1{1..50}

if we want see command manual we have to use man along with command which command
we want know about the man
ex= man rm (here i want know about the rm so that why i use command prompt man)
man = manual.

7.creating a directory or folder


syntax = mkdir directoryname of foldername
mk = make dir = directory name
we can also create multiple directories or folders ,and also we can give range to
create folders
mkdir pradeep{1..20}

8.how to create directory structure.


tree = is a command to visualize the directory structure.
if we want to create direct tree we are using like this
mkdir -p
india/{ap/{kuppam,kbpalli},tn/{chennai,trichy},kl/{trissur,tiruvanthapuram}}
/ = should be there
we are using this -p in automation process

7.removing the directories


empty directories
rmdir directoryname =(rmdir india)
and we can also delete the multiple directories like this but this is only for
empty dir or folder
for non empty directories or folders we have to use
rm -rf directories or folder name
ex = rm -rf india.

8.coping files
if we want copy files we have to use cp(command) with source file and destination
directory.
ex.cp sourcefile destination directory (because one file wont store into another
file we have to use directory)
ex.cp(copingcommands) file(sourcefile) vpradeep(destination directory)
here we are using this if we know the path dir and source file ,or both source file
and dir in same place
thats why we are using this method
if we dont know about the path and source file location and directory
in this type situations we are using this method

9.copieng directories
if we want to know how to copy directories we have to use copy command that is (cp)
and after that source directory destination (<source directory destination> and
after that (<destination directory>)
ex.cp(copy command) vpradeep(source directory destination) vp(destination
directory)
cp vpradeep vp
it wont like this we have to use - rf to copieng the directories from one to
another to copy.
ex.cp -rf source directory destination directory.

10.if we want to see full list details we have to use ls -l


ex.ls - learn

if we want know original time of the file or dir we have to use (p)
to copy files or moving files for not changing the metadata
ex.cp -pvrf pradeep/vp/

**(we have to use pvrf must and should when we have to copy the files or move the
files)

11.moving a file
if we want to move file we have to use the command(mv) with source and destination
directory
ex.mv(moving command) file1(source file) pradeep(destination directory).

if we want move a directory to the another directory


we have to use mv source directory and destination directory
ex .mv(moving command) pradeep(source directory) vp(destination directory)
here -rf we dont need and p also we dont need and v also here for moving.

12.renaming file or directory both are same to rename


here we have to use same mv method for renaming the file or directory
mv oldname newname

You might also like