Some Necessary Linux Command Example

Hello, in this linux commands tutorial i will discuss about some basic linux command which i think every user should know. If you are a developer then it is must needed thing that need to know about some basic linux command.

So let's see some linux commands with examples and syntax. I will give an example with command and code. Let's see one after another.

Create a New File : 

To create a new file, use touch command

touch file.txt

 

To create multiple files, can be done with the help of &&.

touch file_2.txt && touch file_3.txt

 

Create New Directory:

To create a new directory, use mkdir command.

To create a new directory, use mkdir command.

 

Read a File:

There are many ways to read a file like

nano file.txt

 

The second way of reading a file is using cat or more command.

cat file.txt

 

Edit a File:

To edit a file can be done using text editor or related application with the file's type. In this example, the file with .txt extension is edited with text editor using nano.

  1. Open a file with nano command.
nano file.txt

 

Edit file and then Save the file's changes with Ctrl + X then confirm by pressing Y. After that, hit Enter.

View Files:

To view a list of files can be done by using ls command.

ls

 

Move and Copy File:

Wanna move a certain file, use mv command followed with target file and target directory. In this example, the file called file.txt moved to the mydirectory directory.

mv file.txt mydirectory

 

Wanna copy a certain file, use cp command followed with target file and target directory.

cp file_2.txt mydirectory

 

Remove File and Directory:

Wanna remove certain file, use rm command followed with file name.

rm file_2.txt

 

To remove a directory, use rmdir command followed with directory name.

rmdir directory

 

To remove a directory and its content. Use rm -rf.

rm -rf directory_name

 

Want to change the file or directory ownership, use chown command followed with user's name.

chown cool.txt other_user

 

Wanna learn more about specific commands, just add --help

ls --help

 

Hope it can help you.