Linux Commands List for Linux Programming – Part 3

FREE Online Courses: Elevate Your Skills, Zero Cost Attached - Enroll Now!

1. Linux Commands List

This Linux Commands tutorial covers Linux commands list for beginners. It will help you in learning 10 most commonly used Linux commands with syntax to start Linux programming. You will also get few Linux commands with examples here. It will cover commands like pwd, cd, ls, mkdir, rmdir, echo, cat, zcat, cp and mv.

So, let’s learn Linux Commands List.

Linux Commands List for Linux Programming - Part 3

Linux Commands List for Linux Programming – Part 3

2. Linux Commands List

This basic Linux commands list, contains commands with their syntax and usage:

2.1. pwd

a. Usage:

pwd

This Linux command is used to print working directory

b. Usage:

d= `pwd`

This command is used to save current working directory.

c.Usage:

cd $d

This command is used to go back to the saved directory.

2.2. cd

a. Usage:

$ cd /<some path>

This command changes directory to the specified path.

b. Usage:

$ cd

This Linux command will take you to home if path is not mentioned.

c. Usage:

$ cd /

This command is used to go to root directory.

d. Usage:

$ cd ..

This command will move one back towards root directory.

e. Usage:

$ cd –

This Linux command is used to move to the previous directory.

2.3. ls

a. Usage:

$ ls

This command lists all the files and directories in the current working directory.

b. Usage:

$ ls <file or directory name>

This command will list the contents present in the specified file or directory.

c. Usage:

$ ls –l

This Linux command displays file in columns with more details like owner of file, File size, date etc.

d. Usage:

$ ls –hl

This command lists the file in human readable long form(change bytes into kilobytes,gigabytes etc).

e. Usage:

$ ls –hlt

This command lists the file in human readable form sorted by time to last modified.

f. Usage:

$ ls –al

This command lists all files in the directory including dot files.

g. Usage:

$ ls *.txt<may be other extension>

This command lists all the files in the directory which have .txt extension.

2.4. mkdir

a. Usage:

$ mkdir <directory name>

This Linux command makes new directory/folder with mentioned name.

b. Usage:

$ mkdir -p a/b/c

This command creates nested directories a>b>c.

2.5. rmdir

a. Usage:

$ rmdir <empty directory name>

This command removes the directory which is empty.

b. Usage:

$ rm -r <non empty directory>

This command removes non-empty directory.

2.6. echo

a. Usage:

$ echo <String>

This command prints the string passed to echo as an arguments.

b. Usage:

$ echo

This Linux command leaves blank line if you leave arguments.

c. Usage:

$ echo "hello world"

This command prints the given string with spaces.

d. Usage:

$ echo -e "\thello\nworld"

This Linux command interprets special characters.

e. Usage:

$ echo -n <String>

This command suppresses the next line to the given string.

f. Usage:

$ echo $name

This command prints the value containing in name with expanded variable.

2.7. cat

a. Usage:

$ cat file1.txt

This Linux command displays the contents of file1.

b. Usage:

$ cat file1.txt file2.txt

This command displays contents of both the files in different lines.

c. Usage:

$ cat -n file1.txt

This command prints file content with line number.

d. Usage:

$ cat flle1.txt>>file2.txt

This command appends the content of file2 after file1 content.

e. Usage:

$ cat file1.txt file2.txt>>file3.txt

This command appends the content of file1 after the content of file3 and then appends file2 content.

f. Usage:

$ cat file1.txt | wc –l

This Linux command counts the number of lines in the file1.txt.

g. Usage:

$ cat file1.txt | wc –c

This command counts the character in file1 including space.

2.8. zcat

a. Usage:

$ zcat file1.txt.gz

This command display the content of zip file.

2.9. cp

a. Usage:

$ cp file1 file2

This command copies the content of file1 into file 2(overide).

b. Usage:

$ cp -R dir1 dir2

This command recursively copies the dir1 into dir2.

2.10. mv

a. Usage:

$ mv file1 file2

This Linux command renames the file1 by the file2 name.

b. Usage:

$ mv file1 dir1/dir2/file2

This command will move the file1 to dir1/dir2/ and renames file1 by file2.

c. Usage:

$ mv file1 dir1/dir2/

This command will only move the file1 in dir1/dir2.

d. Usage:

$ mv a a.1
$ mv b a
$ mv a.1 b

This command will swipe the name of two files.

e. Usage:

$ mv file1.txt file1.html

shortcut $ mv file1.{txt,html}

This Linux command changes the extension of file1 from .txt to .html.

f. Usage:

mv -n file1 dir1/

If in dir1 the same file1 exists, so it will be overwritten by the file1 which we are moving.

So, this was all about Linux Commands List. Hope you like our explanation. Furthermore, if you have any query, feel free to ask in the comment section.

Learn more commands in Linux Commands – Part 4.

Source

 

You give me 15 seconds I promise you best tutorials
Please share your happy experience on Google

follow dataflair on YouTube

Leave a Reply

Your email address will not be published. Required fields are marked *