Linux Study Notes (1)-file processing commands, linux Study Notes
- List Files And Directories
Ls (list)
# Ls
Enter ls in the terminal and press enter to list the files and directories in the current directory, excluding the hidden files and directories.
# Ls-
List all files in the current directory
# Ls-al
List details of all objects for the current target
- Create directory
Mkdir (make directory)
# Mkdir test
Create the test directory in the current directory
- Show Current Directory
Pwd (print working directory)
# Pwd
Print Current Directory
- Switch to another directory
Cd (change directory)
# Cd directory name
- Copy a file
Cp (copy)
# The folder to which the cp file is to be copied
Copy an object to the specified directory. If the object name is not specified, the source object is named.
- Move files
Mv (move)
Similar to the previous Copy command, only copying files are not generated.
- Delete an object
Rm (remove)
# Rm file to be deleted
Delete the file. Be careful when operating the file.
- Delete directory
Rmdir (remove directory)
Similar to deleting an object
- View File Content
Cat (concatenate)
# Cat file to be viewed
- View help commands
Man (manual)
# Man command to view help
Is the result of input man ls.
Other common operations and commands can be supplemented.
1. linux consists of three parts: the kernel, the shell and the programs ).
Shell is used to connect to the kernel, and the most connected shell in this machine is the terminal. There are many types of shell, which are bash by default in kali, this is also a widely used shell.
2. In the linux world, there are only two things: file and processes.
Everything in UNIX is either a file or a process
3. When you enter commands on a terminal, because of the wide variety of commands, errors may inevitably occur. You can press "tab" for automatic input, and sometimes there will be unintentional results.
4. clear command, clear the content of the current screen. Refreshing
5 ".","..","~ "Content
"." Indicates the current directory
".." Indicates parent directory
"~ "Indicates the Home Directory
6. The preceding prompt "#", # indicates that the current user has the root permission.
7. Why should I add "./" to run the current program, followed by the program name?
This design is for security consideration. If the current directory is a program named ls and has executable permissions, add ". /"will certainly execute the ls program in the current directory. The ls command is frequently used to prevent malicious programs from being executed without the Administrator's knowledge.
# Conclusion #
It's very hot today ......
1. Use the linux directory and file operation commands to complete the following steps: (18 points)
Cd/; mkdir test
Cd test
Mkdir {d1, d2, d3}
Cd d1; touch f1 f2 f3
Rm-f f1; mv f2 ../d2; cp f3 ../d3
Cd ../; rm-rf d3
Date; hwclock -- set -- date = '2014/1/123'; hwclock -- hctosys; date
[It is best to change the time back in the following command]
Tar zcf test.tar.gz *; cp test.tar.gz d1; cd d1; tar zxvf test.tar.gz
Head-n3/root/install. log
Tail-n3/root/install. log
Groupadd testgroup; useradd-g testgroup testroot; passwd testroot
Enter the password deonfu56a twice.
6.
##########################
Vi f5
I
Input a pile of Text
Esc
: Wq
1) ls
2) chmod u + x, g + x f5
3) chown testroot f5
4) wc-lwc f5
############################
7.
1) ll/etc/| more
2) wc-lcw/etc/passwd
3) cd/test; ls-l> f6
Linux processes a column of commands and a command. I want to divide the third column of the file by a fixed value to normalize it!
Perl is also very simple, but you can consider gawk
[Root @ arch ~] # Ls-l
Total 12
Drwxr-xr-x 6 root 4096 Apr 24 file
Drwxr-xr-x 4 root 4096 Apr 23 14:09 setup
Drwxr-xr-x 2 root 4096 May 5 tmp
[Root @ arch ~] # Ls-l | gawk '{$2/= 3; print $0 }'
Total 4
Drwxr-xr-x 2 root 4096 Apr 24 file
Drwxr-xr-x 1.33333 root 4096 Apr 23 14:09 setup
Drwxr-xr-x 0.666667 root 4096 May 5 tmp