Linux Training

Linux Training Tutorials – Linux Basic Commands

Linux Training Tutorials – Linux Basic Commands

Linux basic commands that can create,Remove,Copying,Moving files and directories.

Create Files In Linux:

Cat:

Cat is a command to create a files and modify the file content too.

Syntax: cat > filename

Example: cat > newfile
Welcome to linux

To open the file use the following syntax.

Syntax: cat filename

Example: cat newfile
Welcome to linux

To update the content in the file

Syntax: cat >> filename

Example: cat >> newfile
ctrl+d (exit from the updated file)

Touch:

Touch is the command to create multiple files at time with empty content.

Syntax: touch <filename><filename><filename>

Example: touch file1 file2 file3

To view the created files use the following command,

$ls

Create Directories In Linux:

Mkdir:

mkdir is the command to create directory.Using this command multiple directories can also create.

Syntax: mkdir dirname

Example: mkdir newdir

How to make multiple directories using mkdir,

Options to create multiple directories using options.

example:$mkdir -p dir1/{dir2/{dir5,dir6},dir3/{dir7,dir8},dir3/{dir9,dir10}}

Linux Basic Commands

To view the directories structure use the following command,

Syntax:tree dirname

Example: tree dir1/

Copying Files into single and multiple directories

CP:  

cp command is used to copy files or directories from source to destination(directories).

Syntax: cp <filename><dirname>

Example: cp newfile dir1

To view the copied files in directory follow the below steps,

#cd dir1
#ls

Copy directories from one location to another locations,

Example: cp -rvfp dir1 dir2          (copy dir1 to dir2)
#cd dir2
#ls

MV:

mv command is used to move the files and directories from source location to destination.

Syntax: mv <filename><directoryname>

Example:mv newfile dir1

Move directories from one location to another location,

Example: mv dir1 dir2

Rename the file name with mv command,

Syntax: mv <oldfile><newfile>

Example: mv file1 file2

Rename directory using mv command,

Syntax: mv <oldname><newname>

Example: mv dir1 dir2

RM:

rm is the command to remove files and directories.

Syntax: rm <filename>

Example: rm file1

To remove the files forcefully here is the command,

Syntax: rm -f <Filename>

Removing Empty directory,

While removing directory need to remove files.Here is the example to remove the directory which is empty,

Syntax:rmdir <dirname>

Example: rmdir dir1

Remove directory with files inside,

To remove the directory which contain files in two ways,

1.Remove the files inside the directory and use rmdir command.
2.use rm -rf<dirname> command(r- recursive , f- forcefully)

Syntax: rm -rf<dirname>

Example: rm -rf dir1

Tags:linux,Linux tutorials,Linux commands,Linux online tutorials,Linux latest commands,Tech news,g8k.in,knowledge Articles

About the author

admin

Add Comment

Click here to post a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.