Linux in philosophy - everything is a file
For ease of operation, we can use our secureCRT or Xshell connected to the virtual machine.
Use Remote Tools to connect to a virtual machine, we only need to open ssh service on a virtual machine, fill in the host ip address in xshell, the protocol selection ssh, the username and password for the root user name and password, you can connect to a virtual machine a.
day2 - linux basic commands and directory structure
Like Linux, like windows, also has many of the catalog, we now have to learn each directory under Linux.
To better understand the linux directory structure, I installed a Linux under the name tree package, use the tree command after a successful installation can display the directory tree under Linux. If you install a graphical interface, you can also open a graphical interface to help understand.
yum install tree -y install tree tool #
After installing the tree, we can see the directory structure under the command of Linux
tree -L 1 /
The command line, tree is a directory tree display, -L is a parameter, -L. 1 represents a view only a directory, / is the root directory linux system, all files stored in the root
How, through this picture, we can see, Linux directory structure anatropous like a tree, and / is the world normalized roots
In the following I briefly explain only in the early stages of learning common directory
/boot
Store files related to system startup
/dev
File storage device
/home
The user's home directory,
/root
root user's home directory
/lib
Store executable code file (repository file)
/ mnt
/media
Both directories are the mount point directory
/tmp
Temporary files, all users have read and write permissions on this directory to perform, but did not delete other users permission to modify files, will be emptied once a month.
/where
The variable directory file directory caches, log files in this.
/bin
Binary binary files, executable files stored - the user's command.
/sbin
Storage management commands
Absolute and relative paths
Bound to a file stored in the directory, you need to store the address of a file when we access files in the route we found this document, it is the path.
Absolute path: the date of the beginning of the path from the root directory
Relative path: begin to run from the current directory path
Common file management commands
We can use the cd command to change their location, cd commands that is Chang Directory directory change, when we logged in as root, we are in default under the user's home directory ie / root
cd # change the current directory is located
cd command is a Linux system is the most commonly used commands, there are some quick combinations can greatly enhance the efficiency of our work and study
cd ~ # switch to the user's home directory, root user switches to / the root CD - # before switching to a working directory CD / switch to the root directory #
ls command, that list directory contents view file properties , role in showing the contents of the current working directory
Here are some parameters of the ls command
LS - A # show all files and directories LS - L # show file details LS -o # with - L, but does not display information for the LS -t # The file lists in accordance with the established order in time
ls -d # listed directory itself
As for the other parameters can be viewed with ls --help
Cd now be used in conjunction with the ls command to see all the subdirectories in the root directory
cd /
ls -d *
Operation Example
We already have switched directory, but when we want to get to the current path, how to do it, pwd is such a command, use the pwd can display the absolute path where the direct current
Here are two create command to create a directory mkdir, create a file touch, mkdir -p create directories recursively
mkdir there are two very important parameters
mkdir - the p-# recursively create directories, which can create a directory set directory directory mkdir -v # If there is a directory, not create
Exercise: Create a file /linux/100day/a.txt in the / tmp temporary directory, feel recursively create directories and use the difference between relative and absolute paths of
rm delete files
Two very important parameters rm
rm -r #递归删除 rm -f #删除不再提示
rm正常是不可以删除目录的,加上-r可以进行对于目录的操作,rm -rf是一条杀伤力很强的命令,删除且不提示,网上常说的删库跑路,就是rm -rf *,一定不要乱输
在生产环境中,如果有想删除的文件,往往使用mv移动命令,将要删除的文件移动到/tmp临时目录下,30天后自动清空
mv命令是将文件进行移动,也可以利用mv的原理来进行文件的重命名
练习:在家目录下创建一个b.txt文件,并改名为c.txt
cp复制命令,除了复制外,我们常常使用cp命令来进行文件的备份
cp -r #复制目录下所有子目录和文件
今天就到这里,我们明天来接触文本处理和vim文本编辑器