Linux operating basis (under)

· Linux file link
  • Soft links and hard links

Soft links: do not take up disk space, delete the source file is a soft link failure.

ln -s 源文件 链接文件

Hard Links: taking up disk file, you can generate the equivalent of a hard link to generate a file with multiple file names, delete one will not affect.

ln 源文件 链接文件
· File Search
  • grep

grep searches the file contents (text inside)
format is: grep "" filename extension.

grep "1" name.txt 
# 在name.txt中搜索1
grep -v # 要搜寻的内容取反,可以理解成搜寻除1之外的
grep -i # 不区分大小写搜索 
  • find

find in the computer search for the file
format is:
find directory [-options] conditions

find ./projects name.txt
# 在projects目录中找到name.txt所在位置
find ./projects '*.txt'
#查询文件中所以后缀名为.txt的文件

[-options]

find ./ -size
# 按照文件大小来查找
· Archiving and compression

Computer data often need to back up, tar is a Unix / Linux is the most commonly used backup tool, this command can be a series of archive files into one large file, you can also unlock the archive file to restore the data. tar format using a tar [-options] package file name.

  • takes

tar -cvf 1-2.tar 1.txt 2.txt
the 1.txt, 2.txt archive packaged into 1-2.tar

tar -c # 生成归档文件,创建打包文件
tar -x # 解档
tar -v # 列出归档详细过程
tar -f # 指定档案文件名称,f后面一定接 .tar 文件

** Note that this directory is C before capital letters
tar -zcvf 1-2.tar.gz 1.txt 2.txt - C specify a directory
compression to the specified directory

tar -zxvf 1-2.tar.gz - C specify a directory
to extract the specified directory

  • zip sum unzip
zip -r # 压缩所有子目录
zip -r xxx.zip 被压缩文件名
unzip -d 解压到的路径 xxx.zip
· File permissions Introduction

Use ls -l to view the file permissions
Here Insert Picture Description within the region is represented by filename permissions
nine letters, three groups (owner permission u, group permission g, other user rights o)
Here Insert Picture Description

  • Modify file permissions
letter Explanation
r Read permission, algebraic numbers "4"
w Write permissions, algebraic numbers "2"
x Execute permissions, algebraic numbers "1"
- Does not have any rights, numeric Algebra is "0"

The execution: chmod u = rwx, g = rx, o = r filename is equivalent to: chmod u = 7, g = 5, 0 = 4 filename
simplifies to:

chmod 754 filename

In particular, if you want to modify directory permissions to use a recursive manner, so that it can be modified so the file permissions in the directory

chmod 754 -r filename
· User Management

After the successful installation of ubuntu, are ordinary user privileges, and no maximum root privileges, if necessary, when the use of root privileges, usually in front of the command with sudo. But it has been coupled with sudo sometimes feel a lot of trouble.

  • account number

sudo -s switch the account to your current account to switch to root # $ permanently elevated privileges.
su root use su to switch accounts root, root account initial password: itcast
run can su account name back to the user account name $

  • change the password

Use the command:
passwd 账户to change the password

  • Exit account

exit to return to the previous account, in real terms due to switching accounts in Ubuntu system is a superposition of accounts, so for n times n times to withdraw from the account.

  • ssh remote login
ssh demo@虚拟机IP地址
# 主机的远程登陆

Here involves the IP address of the virtual machine, we can use ifconfigto query.
That landed the host can execute the commands in bash for virtual machine operations.

  • scp remote copy

Upload
to upload local files to the server

scp 本地路径 服务器用户名@服务器地址:远程路径
#如:
scp ./1.txt [email protected]:/home/kaka/projects/1.txt

Download
download files from the server to the local

scp 服务器用户名@服务器地址:远程路径 本地路径
#如:
scp [email protected]:/home/kaka/projects/1.txt ./1.txt

Because the data flow is from left to right, so uploading and downloading command format will be different.

Released three original articles · won praise 2 · Views 101

Guess you like

Origin blog.csdn.net/weixin_45004260/article/details/104455166