7 Linux commands basically work with files and folders

0
160

7 Linux commands basically work with files and folders. When working with Linux, we often use Terminal. Here are 7 commonly used commands when we work with files and directories.

You can try Linux directly when using Windows 10. Read this article Install Ubuntu on Windows 10

1. Change working directory – 7 Linux commands basically

Usually, to change certain folders you will have to navigate through the directories. However, on the Terminal, we use the cd command.

Suppose you need to access the Downloads folder:

cd Download

Also you can navigate directly to the subdirectory of the Download folder, using the command:

cd Download/sub-folder

To return to the previous folder you used:

cd ..

2. Create a new folder

mkdir is also one of the commands that users often use. This command is used to create a new directory with a specific name.

For example, you want to create the linux_tutorital directory

mkdir linux_tutorial

In addition, you can also create multiple folders at once, for example if you want to create 3 folders named linux, windows, macos

mkdir linux windows macos

3. Create a new file

Use the touch command to create an empty file. Such as:

touch test.txt

Also you can specify multiple file names to create multiple files at once, such as

touch hello.txt world.html

4. Move files

Use the mv command to move a specific file to a directory. For example, if you want to move the index.html file to the directory named /hello-world

mv index.html /hello-world

You can also use the mv command to change file names and directories. For example, if you want to rename index.html to about.html, use the following command:

mv index.html about.html

5. Copy files

Use the cp command  if you want to copy a file or a directory.

For example, if you want to copy index.html and name the new file about.html, use the following command:

cp index.html about.html

6. Show folder contents

Use the ls command to display the contents of the directory

ls

7. Open file

Use the open command to open the files of the directory in the default application. For example, to open the Desktop folder on the Finder, use the following command:

open ~/Desktop

Alternatively, you can open the file using the default editing application on your device. For example:

open index.html

Linux provides Vim editor to open and edit files. You can use:

vim index.html

There are 7 basic Linux commands when working with files and folders. Wish you are proficient with Linux. Thank you for reading.

Leave a Reply

avatar