UNIX Shell Basics Summary (ii)

Source: Internet
Author: User
Tags disk usage

1. The relationship between Vim,vi and ex

Vim does not need to install, VI for ex "Visual Mode", Vim is the advanced version of VI;

2. Unix Shell shortcut keys

ctrl+a/e position the cursor to the head/tail of the command

ctrl+u/k ctrl+y Paste ctrl+u/k content before/after cutting the cursor

3. Time extraction in the Unix shell

dt= "' Date +%f '"//2017-09-27

yy= "' Date +%y '"//2017

Mm= "' Date +%m '"//09

Dd= "' Date +%d '"//27

Hh= "' Date +%h '"//16

nn= "' Date +%m '"//10

4. Export setting or displaying environment variables

A. View: Export

B. Settings: Export path= "$PATH: XXX"

5. Explanation of why the command line must be added./or bash to execute the command file:

UNIX searches the user's current path by $path variable, and the current path is not included in this variable, so add "./" to indicate. So you can use the command export path= $PATH:./Add the current path to $path, and enter the file name directly on the command line!

8. Timed execution of Crontab

Special symbol Description:*: any moment;,: split; /N: Executes once per n units;

Example: 0 2 * * */test.sh > Output.file 2 >& 1 &

Function: Redirect error output 2 to standard output 1, and then save standard output 1 to file output.file;

Use: Open the following file and add the sample code above:

9. Output redirect 2>&1 &

In Bash, 0,1,2 represents Stdin_fileno,stdout_fileno,stderr_fileno, which is standard input, standard output, and standard error, respectively;

For 2>&1 &, refers to redirecting standard error 2 to standard output 1. At this point, the & in front of 1 is for Bash to interpret 1 as standard output instead of file 1. As for the last &, let Bash run in the background;

10. View the disk usage view:

Du (Disk Usage): Per-file statistics, can cross-region;

DF (Disk free): Directly read the partition's Super block information;

11. About "~" in Unix

For the root user, "~" represents the root user;

For general users, "~" represents the current user's directory, such as/joyezhou

12. Problem: Files created in Windows, why is it always less than one line when UNIX is downgraded with xc-l?

In the Windows operating system, the file takes ' \ n ' as a terminator. So the last line will be lost if it doesn't. UNIX will automatically add \ n at the end of the file, plus the file terminator eof, so there is a compatibility problem with Windows files under UNIX.

13. About Ksh invoke script File Execution command

When you invoke a script file on the bash command line, you need to use Ksh to make the call, but the current script file must have executable permission X when invoking the script.

14. File Rights Management

chmod: Change the access rights of the file or directory (set folder permissions first);

User group permissions: R (Read:4) W (write:2) x (execute:1)

* There are 10 bits here, the first is the file type, the remaining 9 bits consist of three ternary character rwx. The first ternary group represents the permissions of the file owner, the second group represents the permissions of the file user group, and the third group represents the permissions of all other users;

Specific example: chmod 777 FileName (777 for full open access);

Chown: Change the owner of a file or directory;

CHGRP: Change the user group of the file/directory;

UNIX Shell Basics Summary (ii)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.