10 minutes to learn Linux

  

10 minutes to learn Linux is a bit exaggerated, but can let a novice get familiar with the most important and basic knowledge of Linux, the English translation of this article is very good in many Linux entry learning materials.

English address: http://freeengineer.org/learnUNIXin10minutes.html

Chinese translation is as follows:

Foreword This is what I have given to students in the past few years ( CAD User Training) Materials used in the training.

The purpose is to use the basic commands of the UNIX shell on a single page. (So ​​they didn't call and ask me).

This document is protected by copyright but is freely distributed under the terms of GFDL. Any thoughts on this page? Feel free to send me supplements, comments, corrections, anything you think is wrong or should be included. I am always happy to hear from you, please include the words "UNIX" in the header of your email.

1. Directories (directory)

2. Moving around the file system (

3. Listing directory contents (listing directory contents)< Br>

4. Changing file permissions and attributes

5. Moving, renaming, and copying files

6. Viewing and editing files

7. Shells

8. Environment variables

9. Interactive History< Br>

10. Filename Completion

11. Bash is the way cool shell. (Bash is a cool shell)

12. Redirection Orientation)

13.Pipes (pipeline)

14.Command Substitution (command substitution)

15.Searching for strings in files: The grep command (Search in files) String: grep command)

16.Searching for files : The find command (search file: find command)

17.Reading and writing tapes, backups, and archives: The tar command ( Read Write to tape, backup and archive: tar command)

18.File compression: compress, gzip, and bzip2 (file compression: compress, zip and bzip2)

19.Looking for help: The man and apropos commands (seeking help: man and apropos commands)

20.Basics of the vi editor (the basics of vi editor)

1 Contents:
In UNIX The file and directory paths use forward slashes “/” to separate directories in one path.

Example: /root directory /usr directory usr (root directory /subdirectory) /usr/STRIM100 STRIM100 is a subdirectory of /usr

2 Move location in file system

Pwd displays the current working directory, or displays the current directory

cd changes the current directory to the current user's home directory

cd /usr/STRIM100 changes the current directory to the directory /usr/STRIM100

cd INIT Change the current directory to the subdirectory of the current directory INIT

cd .. Change the current directory to the previous directory

cd $STRMWORK Change the current directory to the directory defined by the environment variable STRMWORK

cd ~bob Change the current directory to the home directory of the user bob (if you have permission)

3 List the contents of the directory

ls List the contents of the directory ls -l Listing directories in long format (details)

Example:

$ ls -l
File permissions Number of links or directory contents File owner User group File size Date and time File name drwxr-xr-x 4 cliff user 1024 Jun 18 09 :40 WAITRON_EARNINGS -rw-r--r-- 4 cliff user 767392 Jun 6 14:28 scanlib.tar.gz

File permissions (drwxr-xr-x, -rw-r--r--)< Br>

The first bit represents the file type: - = normal file, d= directory, l = link symbol, and so on.

The first (2, 3, 4) bits represent the permissions of the file (all users except the owner's user group)

The (5,6,7) bits represent the file. Permissions (users in the same group as the owner)

Bits (8, 9, 10) represent the permissions of the file (for the owner)

r = read, w = write, x = Execute - = Missing

ls -a

Lists the current directory and contains hidden files. Implicit files begin with "."

ls -ld *< Br>

List all files and directories in the long format using the current directory.

Without d, all the files are listed.

If you have d, list all the files and directories

4 Change the permissions and attributes of the file< Br>

chmod 755 file change file permissions, owner RWX, user group for other users RX (7 = rwx = 111 binary 5 = RX = 101 binary)

chgrp user File Makes the file belong to the user of the group.

chown cliff file Make user cliff a file owner

chown -R cliff dir Make the user the owner of the directory dir and everything under the directory tree

You must ensure that you are the owner of the file/directory or have root privileges before you do the above

5 Move, rename and copy files

cp file1 file2 Copy files mv file1 newname Move or Rename a file mv file1 ~/AAA/Move file file1 into the AAA subdirectory under your home directory rm file1 [file2 ...] Remove or delete a file (is there a difference?) rm -r dir1 [dir2. ..] Recursively delete a directory and the contents of the directory (be careful!) mkdir dir1 [dir2...] Create directory mkdir -p dirpath Create directory dirpath, and all hidden directories in the path rmdir dir1 [dir2.. .] Remove an empty directory

6 View and edit the file

cat filename Export the contents of the file to the screen in ascii more filename Progressively export all the contents of the file to the screen, press ENTER = Add a line to SPACEBAR = add one page down q= to exit Less filename Just like more, but you can use the previous page, not all systems support vi filename Edit a file with the VI editor, all Unix systems have some form of VI emacs filename Edit an emacs editor File, not all systems have emacs head filename Display the first few lines of a file head -n filename Display the first n lines of a file tail filename Display the last few lines of a file tail -n filename Display the last n lines of a file < Br>

7 Shells

The command line behavior will be slightly different depending on the shell program you use.

Depending on the shell you are using, some extra behavior can be quite good. You can view it. The shell used uses the following password: echo $SHELL Of course, you can create a file containing a series of shell commands to execute it like a program, and complete a task. This is called a shell script.

This is actually the main purpose of many shells, not the interaction of command line behavior.

8 Environment Variables

You can teach your shell to remember something to use environment variables later.

For example, in the bash shell environment:

export CASROOT=/usr/local/CAS3.0 defines the value of the variable CASROOT as /usr/local/CAS3.0

export LD_LIBRARY_PATH=$CASROOT/Linux/lib defines the value of the variable LD_LIBRARY_PATH: the value of the variable CASROOT plus /Linux/lib,

Copyright © Windows knowledge All Rights Reserved