[Linux] Commands and permissions

5a2585dded9b416fb4ea58637b42ed39.png

  Yan-yingjie's homepage

Awareness of the past, not remonstrance, knowing the future, can be pursued  

C++ programmer, 2024 electronic information graduate student


Table of contents

1. Xshell configuration

       session configuration                                                                           

         log

2. Instructions

        date command

        cal command

        find command (very important) -name

        grep command

      

        zip/unzip command

        question:

                        Why pack and compress?

        tar command

        uname command

        Commonly used hotkeys

3. Shell command and operating principle

        How to understand? Why can't I use the kernel directly?


1. Xshell configuration

       session configuration                                                                           

         Connect again to succeed

         log

                At every critical moment when the program runs to itself, you need to log it yourself

                Log: the time of the log, the level of the log, the specific information of the log, and other information, write the previous information to a

in a file, which we call the log

2. Instructions

        date command

//时间戳
date %s

//如何将时间戳内的时间转换成我们能看得懂的时间
date +%Y:%m:%d_%H:%M:%S

//查看时间戳的起始时间--欧洲时间,这就是为什么我们查看的时间不是0点,而是八点
//这是因为东八区的时间和欧洲时间相差八小时
date +%Y:%m:%d_%H:%M:%S -d @0

         The calculation of the timestamp time is actually calculated from January 1, 1970, and it is monotonically increasing

        cal command

                calendar function

//查看本月的日历
cal

//查看指定年日历
cal 2023
cal 1949

      

        find command (very important) -name

               

//查找指定文件的路径
find ~ -name test.c

//搜索指令位置

which ls

which find


//whereis指令:在系统特定路径下查找,既可以找到特定可执行程序,又可以找到手册,
//安装包,压缩包等等

whereis ll

        grep command

                Line text filtering tool, line matching, if it matches, print it, if it does not match, filter it out

//行过滤
grep  "world" test.c

//行过滤,同时忽略大小写
grep -i "world" test.c

//打印需要找到的命令的行数
grep -n "world" test.c 

        

      

        zip/unzip command

                

//压缩文件
zip d1.zip d1

//解压缩
unzip d1.zip

//压缩指定文件
zip -r d1.zip d1 log.txt

//进入管理员账号
su -
//然后输入密码即可
//再退出时,直接ctrl+D

        question:

                        Why pack and compress?

                        What can be packaged and compressed must be a whole (dependency program), and one file is programmed from multiple files.

It is not easy to cause file loss, and packaging and compression can make the volume smaller (large volume, long download time, and large storage space)

        tar command

                Packing/unpacking does not open, directly view the content

                

//打包压缩
tar czf code.tgz d1
//tar->打包后缀
//.gz->压缩后缀

//预览
tar tzf code.tgz


//bc指令是Linux下的计算器

        uname command

                View server details

//查看主机的详细信息
//体系结构 内核版本
uname -a

//查看CPU的详细信息
lscpu

//向文件内输入内容
nano test.c

        Commonly used hotkeys

               Tab---command completion Tab---click twice to display system commands ctr+r to view recent historical commands

3. Shell commands and operating principles

        Strictly speaking, Linux is an operating system, which we call " kernel " , but we general users, don't
Can directly use the kernel . Instead, it communicates with the kernel through the kernel 's " shell " program, the so-called shell .

        How to understand? Why can't we use the kernel directly ?

From a technical point of view, the simplest definition of         Shell : command line interpreter ( command Interpreter ) mainly includes:
Translate user commands to the core ( kernel ) for processing.
At the same time, the processing results of the core are translated to the user.
        Compared with windows GUI , we operate windows not directly operate the windows kernel, but through the graphical interface, click to complete our operations (for example, to enter the operation of the D drive, we usually double-click the D drive letter . Or run an application) . The shell has the same function for Linux , mainly to parse our instructions and send them to the Linux kernel. Feedback results are generated through the kernel and parsed to the user through the shell .

Guess you like

Origin blog.csdn.net/m0_73367097/article/details/130845234
Recommended