Basic commands for operating Linux files linux system admin
If you are reading now, I will explain that you can build a Linux environment and log in. If you haven't created a Linux environment yet , read How to Build an Environment .
The account used below is testac and the host name is some1.
Current directory view pwd
pwd is a command that shows which directory you are currently in. Running pwd will show you the current directory. Immediately after logging in, you will be in the / home / account name directory
testac @ some1: ~ $ pwd
/ home / testac
View files in directory ls
ls is a command to display the files and directories in the current directory. Run ls to see a list of files and directories.
testac @ some1: ~ $ ls
file1.txt file2.txt folder1
Move directory cd
cd is a command to move directories. The first is in the / home / account name / directory. cd to folder1.
testac @ some1: ~ $ cd folder1 /
testac @ some1: ~ / folder1 $ pwd
/ home / testac / folder1
If you want to move to the next higher directory, use cd .. .. means the next higher directory. The current directory is. The directory two above is not ... but ../ ..
testac @ some1: ~ / folder1 $ cd ..
testac @ some1: ~ $ pwd
/ home / testac
Move and rename files mv
mv is a command to move and rename files. When you specify a file with the location / file name and full path, changing the location will move it, and changing the file name will rename it.
Format is mv Current file (directory) name Renamed file (directory) name.
Change file1.txt to fileA.txt
testac @ some1: ~ $ mv file1.txt fileA.txt
testac @ some1: ~ $ ls
file2.txt fileA.txt folder1
Move file1.txt to folder1
testac @ some1: ~ $ mv file2.txt folder1 /
testac @ some1: ~ $ ls folder1 /
file2.txt
Copy files and directories cp
cp copies files and directories. Faomat is cp copied to copy destination of .
testac @ some1: ~ / folder1 $ cp file2.txt fileB.txt
testac @ some1: ~ / folder1 $ ls
file2.txt fileB.txt
When I try to copy a directory with contents with cp, it cannot be executed with an error. When copying a directory, add -R to cp to copy the contents of the directory as well.
testac @ some1: ~ $ cp -r folder1 folderB
testac @ some1: ~ $ ls
folder1 folderB
Delete directories and files rm
Delete the file.
testac @ some1: ~ $ rm file1.txt
Add -R to delete the directory.
testac @ some1: ~ $ rm -R folder1 /
File content display more
View the contents of the file
testac@some1: ~ $ more file1.txt
Hello
World
Log out exit
Log out of that account.
testac @ some1: ~ $ exit
logout
Summary
In this article, I have selected and introduced eight file operation commands that people who are new to Linux must use. However, it does not mean that you only need to know these eight. The eight commands introduced this time are only those that are really necessary at the beginning.
In addition to this, we will introduce how to use essential commands such as vi and apt if you manage Linux.
No comments:
Post a Comment