LINUX simple command

xiaoxiao2021-04-10  518

LINUX simple command

Start and close the system Linux Shells use Bash Shell

AT ---- Arrange, Check, Delete Work CAT ---- Connection File and Print to Standard Output CD ---- Change the Directory, can handle the absolute and relative path chmod ---- Change file protection permissions Chown ---- Change the owner of the document and Group CLEAR ---- Clear the screen (CLS in DOS) CP ---- Copy file crontab ---- Operate the daemon of each user and the schedule DATE ---- Print or set the system date and time DD ---- copy a file (and can translate it at the same time) DF ---- Report disk remaining space du ---- Report disk space usage File ------ Detection file and directory type Find ---- Search Directory Document Grep ---- Search Matching Rows in the File and Output Gzip ---- Compress or Expand the File Head ---- "The first few lines of the file" HISTORY --- Display history command Record Kill ---- Stop a process last ---- Show how many users or terminals in the past login to this machine LESS ---- I want to press the more command to display the file LN --- - Establish connection between files ---- List the files in the current directory Man ---- Show online manual more in a certain format ---- Command can read the text MOUNT ---- Install a file System MV ---- Rename Passwd ---- Set the user's password PS ---- Command Run Run the process REBOOT ---- Restart the system RM ---- command to delete the file su ---- Create and edit UNIX archive tar ---- Create and edit UNIX archive Touch ---- Change the time parameter wc of the file ---- Counting the number of bytes in a file, the number of words, the number of lines WHO --- - Review other login users Which-

--- Which - Display Command's full path ping ---- Command - Determine if the machine is accessible or reaches the rate of multiple task output redirects to understand the process

There are two operating interfaces in the Linux system, namely the X window mode (default is KDE) and console mode. The two operating interfaces are similar to Windows and DOS.

If you want to transform into a console mode in X Window mode, you only need to press the Alt F1 (or F2 ... F6) button at the same time, the screen will appear new add-in window, you can log in to the system. If you want to return X-window mode in the console mode, you need to press the Ctrl Alt F7 button at the same time.

If you do not start the X window mode, you want to start the X-window mode from the console mode, enter: StartX (or KDM) in the console mode, you can start the X window.

In the above two chapters, we have already introduced the operation of the X window (default KDE). In this chapter and next chapter, we will focus on the operation in console mode, and will also interrupted the corresponding KDE operation.

6.1 Launching and closing the system

Start system

If you have installed LILO during the installation, you can start the system, LILO starts, the screen display:

LILO:

Click the Tab key and the screen will display all operating systems that can be started. Type the displayed operating system name, you can start the appropriate operating system. Type Linux to start BluePoint Linux & 127; If you click the Enter key or wait for 5 seconds, you can also start the BluePoint Linux & 127; the operating system.

Another way to start the Linux system is: Run Loadlin.exe under the DOS / Windows system. See the appropriate information for specific usage.

Login program

The Linux system is a multi-user system. If you want to use the system, you have to identify the user's identity, which is the so-called registration program. During the installation process, we have created a ROOT super user account. After the system starts the system, in the login command line, type root, then enter the password ("password"). If the password is correct, login is successful.

Recommendation: After entering the system, establish a second account (non-privileged user) for everyday use.

Because the root account has the resource ownership of the entire system, it is a management account rather than a work account.

If you want to create a job account, you need two steps:

Step 1: Create a user registration account.

Type: addusr login_name

Where login_name is the registered account you choose (do not use root).

Step 2: Create an account password.

Type: Passwd login_password

Where login_password is the account password you selected (it is best not to be the same as the root password).

If the normal user wants to use the system's privilege, use the su command, and enter the root password in the root command line. In addition, you can also use the Super User Mode File Manager to get system resources, how to use is:

"K Menu" -> System Application "->" File Manager (Super User Mode) "

If your colleague (family member ...) should use your computer system, you should create a new user account for these users, and you cannot tell them the root account. Note: You have to take advantage of Linux is the advantage of multi-user operating system.

Shut down system

There are many ways to turn off the system, but don't directly turn off the power!

Because Linux is to speed up input / output using cache and disk (hard disk, floppy disk ...); if the power is turned off directly, the data stored may not be truly written to disk, which may result in data loss. The correct shutdown system is the following:

Type / Sbin / Halt Command (or Type Halt directly), wait for the system hangs (Systemhalted) Re-shutdown system fast shutdown system method is simultaneously pressing the Ctrl Alt DEL key (like DOS), the system will uninstall all periphery The device is turned off when the computer is initialized, and then turn off. Use the KDM session. Right click on the desktop and select "Logout". Select "Close" system or "restart" system.

What happens if the power is turned off directly or a power out? Linux reacts the system when the system is not properly uninstalled (FSCK operation). After a few minutes. The system may start correctly.

6.2 Linux's shells

Once entering the system, you will see a prompt that prompts you to type the command. The program of this waiting command called Shell, which is to transmit the instruction to the kernel of Linux.

There are many different shells in the Linux system: Bash, CSH, KSH, TCSH, SH, ZSH ...

In BluePoint Linux & 127; system system, shell uses "Bash" because Bash Shell is simple and powerful.

If you want to know what the current use is the kind of shell, you just type: Echo $ shell

You can find the shell type that the system is using.

Note: Different shells have different syntax.

6.3 Using Bash Shell

Like the DOS system, the Linux system console also uses a command line. You need to enter a command on the console will be executed.

Shortcut

General keyboard shortcuts is:

Ctrl A to start

Ctrl u Clear the current line

Ctrl C stops running procedures

. Use the semicolon to type several commands in the same row.

The up and down keys can get the command history.

Automatic name

Under the Linux system, the program and command names are sometimes very long, BASH supports automatic name to make full functionality.

You start to type the command name, then the Tab key, the system will automatically complete the command or program or directory name.

For example: If you want to use a decompression program Bunzip. Type

$ bu

Then click on the Tab: BASH will display all the names starting with the Bu. E.g:

Buildhash Buildin Bunzip

Type n (bunzip2 is the only name third character is n), then hit the Tab key. The shell will give you a full name on the command, you can execute the bunzip2 command.

AT command

AT, BATCH, ATQ, ATRM: Arrange, Check, Delete the work in the queue.

AT [-V] [- Q Queue] [- F file name] [- mlbv] time

AT-C homework [job ...]

ATQ [-V] [-Q queue] [- v]

ATRM [-V] homework [job ...]

BATCH [-V] [-Q queue] [-f file name] [-MV] [Time]

AT performs jobs at the set time.

ATQ lists jobs in the queue in the queue. If you are a superuser, list all your jobs in the queue.

ATRM deletes jobs in the queue.

Batch runs jobs with low priority, as long as the system's Loadavg (system average load) <1.5 (or value set in ATRUN), it can start the job.

Super users can use the AT series in any case. General users use the permissions of the AT series commands by file /etc/at.allow/etc/at.deny. If /etc/at.allow exists, only the users listed in this file can use the AT series command. If the /etc/at.allow file does not exist, check the file /etc/at.deny this file. As long as users listed in this file can use the AT series of commands. The default configuration is that the file /etc/at.deny is an empty file, which indicates that all users can use the A series of commands. E.g:

In two days, the job in Workfile is executed in 8 am.

[Test @ bluepoint /] $ at -f workfile 8 am 2 days

CAT command

CAT --- Connect the file and print it to the standard output.

Cat is often used to display files, similar to DOS command Type.

E.g:

Display the contents of file file

[Test @ bluepoint /] $ cat file

Connect the file1, file2 to the file file3.

[Test @ bluepoint /] $ cat file1 file2> file3

CD command

CD --- Change the directory to handle absolute and relative paths.

E.g:

If you are currently in the root directory, you want to enter the ETC / subdirectory. Type (relative directory):

[Test @ bluepoint /] $ CD ETC /

If you want to enter the / usr / bin directory, type (absolute directory):

[Test @ bluepoint /] $ CD / USR / BIN /

Some utilities are:

Back to the parent directory (note that there is space between CD and ..)

[Test @ bluepoint /] $ cd ..

Go back to the current directory.

[Test @ bluepoint /] $ CD.

CD ~ arrive at the individual directory

[Test @ bluepoint /] $ CD ~

CHMOD command

CHMOD - change file protection permissions

File protection controls users' access rights to files, three security levels: owner level, group access level, other user access level. In these three levels, there are three privileges: read (r), write (W), execute (X). (Users can use the ls -lg command to watch the group of the belonging of a file).

For documents, read permissions means that you can see the contents of the file, write file rights can modify or delete files, and execute it. For directory, read rights means to view the contents of the directory, write permissions mean that new files can be created in the directory, and can remove files from the directory, and execute permissions means to another directory from a directory to another.

Protection Permissions: Format is [UGOA] [[ - =] [RWXXSTUGO ...] ...] [....] "UGOA" control which users will change the file permissions: (u) file owner, (g) File owner's group of users, (0) users of other groups, (a) all users. Operators " " make user permissions to be added to each directory file. Operators "-" make user permissions to be canceled, operator "=" User users only have these privileges. "RWXXSTUGO" Selects New Properties: (R) Read Permissions (W) Write Permissions (X) Execution Permissions (and Access to Directory) (X) Only the target file is executable or the target file is The X attribute (S) is added to the Directory to set the text to the switchboard (U) target file owner (G) The group (O) of the target file owner (G) target file owner. If the number is indicated by the attribute, (0) No permission (1) Execution (2) read rights (4) write rights, then add, the format of the digital attribute should be 3 0 to 7 octal number, its order Yes (u) (g) (o) file name: Separate a list of files to change permissions, support wildcard.

example:

Make all users with the file testfile

[Test @ bluepoint /] $ chmod a x testfile

Make all users to read the file Testfile

[Test @ bluepoint /] $ chmod 222 testfile

Chown command

Chown - Change the owner and group of the file.

User: Yes may be a username or user ID.

Group: It can be a group name or group ID.

File Name: Separate the list of files to change permissions, support wildcard.

E.g:

[Test @ bluepoint /] $ chown host: test file1

Change the file File1 host to the TEST of the Host group.

CLEAR command

CLEAR - Clear the screen (like the CLS in DOS).

E.g:

[Test @ bluepoint /] $ CLEAR

Clear the screen, the prompt will move to the upper left corner.

CP command

CP - copy file

usage:

CP [Options] Source File Target File

Option:

-f, - force: Forcibly override the existing target file

-i, -interactive: gives a prompt when it is forcibly covered the existing target file.

-R, - Recursive: Copy the entire directory.

E.g:

[Test @ bluepoint /] CP SourceFile destfile

Copy files Sourcefile to file destfile.

CRONTAB command

crontab - Operate the daemon and schedule of each user's daemon and execution.

Crontab file [-u user] - replaces the current crontab with the specified file.

Crontab - [-U user] - replaces the current crontab with standard input.

crontab -l [User] - Lists the current crontab.

Crontab -e [user] - Edit the user's current crontab.

crontab -D [user] - Delete the user's current crontab.

crontab-C Dir - Specifies the directory of crontab.

CRONTAB file format: M h D m D cmd

M: Minute (0-59)

H: Hours (0-23)

D: Day (1-31)

M: Month (1-12)

D: Day in a week (0-6, 0 is Sunday)

CMD: To run the program, the program is sent to the shell execution, this shell is only the User, HOME, the three environment variables.

E.g:

List the current crontab

[Test @ bluepoint /] $ crontab -l

$ MIN HOUR Day Mouth Dayofweek Command

8 6 * * * Clear

[Test @ bluepoint /] $

Date command

Date - Print or set the system date and time

Date [-u] [-d datestr] [-s datestr] [- outc] [- universal] [- date = datestr] [- set = datestr] [--help] [- version] [ FORMAT] [MMDDHMM [[CC] YY]. SS]]

Format: Control how to display the date.

Directive:%:%

N: New line

T: Tab

Time domain

% H hours (@..23)

% l Hours (00..12)

% K hours (0..23)

% l Hours (1..12)

% M Hours (00..59)

% P AM or PM

% R 12 hours (hh: mm: ss [AP] M)

% S starts from 1970-01-01 00:00:00 UTC

% S second (00..59)

% T Time Representation (% h:% m:% s)

% Z time zone (such as EDT). If there is no designated time zone, it is not displayed.

Date domain:

Pertenic name in% a abbreviation (Sun..SAT)

% A star name (sunday..saturday)

% B abbreviation form of the month (JAN..DEC)% B month name (January..December)

% C Date and Time (Sat Nov 0:02:33 EST 1989)

% D for the first few days of each month (01..31)

% D Date (mm / dd / yy)

% H is equivalent to% B

% J a year of the year (001..366)

% M Month (01..12)

% U is the first day of the week, the first day of the week (00:53)

The first few days of% W, (0..6) is Sunday

The first day of the week, the first day of Week, Monday (00:53)

% x Date (mm / dd / yy)

The last two numbers of% y year (@99)

% Y year (1970 ..)

[Mmddhhmm [[cc] yy]. SS]]

MM month

DD date

HH hours

MM minute

The first two digits in CC year (optional)

After YY years (optional)

SS Second (optional)

Only super users have permission to set the system time (read in CMOS during startup).

-d DateStr, --Date dates: Displays the date and time specified in DateStr.

-S dateStr, --Set DateStr: Set the date and time specified in DateStr.

-u, - universal: Show or set Greenwich time (default is local time)

--help: Output help information on standard output and exits.

--Version: Output version information on standard output and exits.

E.g:

Show current time:

[Test @ bluepoint /] $ date -u --date '2 days ago'

Tue aug 24 10:20:39 UTC 1999

Month

[Test @ bluepoint /] $ date ' % b% d'

August 24

DD command

DD - copy a file (and can transform it at the same time)

E.g:

Copy the file Sourcefile to the file destfile.

[Test @ bluepoint /] $ dd if = sourcefile of = destfile

0 1 RECORDS IN

0 1 RECORDS OUT

[Test @ bluepoint /] $

DF command

DF - Report the remaining space of the disk.

E.g:

[Test @ TBLuePoint /] $ df -a -t

FileSystem Type 1k-block Used Available Use% MOUNTED ON

/ DEV / SDA1 EXT2 1020541 846524 121288 87% /

None Proc 0 0 0 - / Proc

None Devpts 0 0 0 - / DEV / PTS

/ DEV / HAD2 EXT2 1149143 927921 161851 85% / Work

[Test @ TBLuePoint /] $

Du command

DU - report disk space usage

E.g

[Test @ bluepoint /] $ du

366 ./USR/doc/gnome-libs-devel-1.0.9/devel-docs/gnome/html

243 ./usr/doc/gnome-libs-devel-1.0.9/devel-docs/gnome/sgml

53 ./usr/doc/gnome-libs-devel-1.0.9/devel-docs/gnome/tmpl

729 ./usr/doc/gnome-libs-devel-1.0.9/devel-docs/gnome

[Test @ bluepoint /] $

File command

File - Detection Files and Directory Types

[Test @ bluepoint /] $ file boot

Boot: Directory

[Test @ bluepoint /] $

Find command

Find - Search Document Find [Path.] [Match Expression]

example

Find a file or directory for the name "passwd" throughout the file system

[Test @ bluepoint /] $ find ./ --Name "passwd" -print

./etc/passwd

./etc/pam.d/passwd

./etc/uucp/passwd

./Home/ftp/etc/passwd

./USR/bin/passwd

./USR/doc/uucp-1.06.1/sample/passwd

[Test @ bluepoint /] $

grep command

GREP, EGREP, FGREP - Search the matching row in the file and output it.

E.g:

In the file / etc / passwd lookup row with root

[Test @ bluepoint /] $ grep root / etc / passwd

Root: x: 0: 0: root: / root: / bin / bash

Operator: x: 11: 0: Operator: / root:

[Test @ bluepoint /] $

gzip command

Gzip, gunzip, zcat - compression or expand file

[TEST $ BluePoint /] $ GZIP -V Sourcefile

Sourcefile: 15.2% - Replaced with sourcefile.gz

[Test @ bluepoint /] $

HEAD command

HEAD - a few lines of displaying files

example

Output file / ETC / crontab first line

[Test @ bluepoint /] $ head -n 1 / etc / crontab

Shell = / bin / bash

[Test @ bluepoint /] $

History command

Histoty - Displays history command records.

There is a record number in the screen display history command, and each history command has a record number. To perform a command, type:

Command_number

This command will be re-executed.

Command !!, will re-execute the last command.

Kill command

Kill - stop a process

Kill [-s signal | P] [- a] process number

Kill -l [signal]

KILL emits a specific signal to the specified process. If the signal is not specified, the TERM signal is sent, the TERM signal will kill the process of capturing this signal. For some might try to use Kill (9) signals to kill.

E.g:

[Test @ bluepoint / root] $ ps

PID TTY TIME CMD

520 PTS / 0 00:00:00 Bash

523 PTS / 0 00:00:00 PS

[Test @ bluepoint / root] $

Last command

Last - shows how many users or terminals in the past are logged in to this machine.

Last [- Number] [-f file] [-t tty] [- h node name] [- I ip address] [- l] [- y] [user name ...]

E.g:

Shows the case of the past 3 user root login.

[Test @ bluepoint /] last -3 root

Root 0 Wed Aug 25 14:07 Still Logged in

Root 0 WED AUG 25 14:02 - 14:03 (00:00)

Root: 0 Wed Aug 25 14:01 - 14:01 (00:00)

WTMP Begins Tue aug 17 17:27:41 1999

[Test @ TBLuePoint /] $

LESS command

LESS - wants to display files by page for more commands.

E.g:

Displays the file test.

[Test @ bluepoint /] LEST TEST

ln command

LN - Establish a connection between files LN [Parameters] Source File [Target File]

Establish a connection LN [parameter] source file [Directory] in the directory room [Directory] Note: It is meaningless to change the properties for the connection file, because only the files they are connected are the true properties of the file.

E.g:

Connect the file SourceFile to the file testfile

[Test @ TBLUEPOINT /] $ ln -s sourcefile testfile

[Test @ TBLuePoint /] $

ls command

LS Command - List the files in the current directory, the commonly used options are: -a display hidden files and -l display long file names, will add a directory name to the LS command. E.g:

LS -AL / usr / x11r6 / bin

Type:

[test @ TBLuePoint /] $ man ls

All LS command options will be displayed.

man command

Man - display online manual with a certain format

The man command is a useful tool for novices and olders. Programmaker can use this command to see the C function.

Here is the classification of common UNIX manuals:

1 user command

2 system call

3 library functions

4 device and device driver

5 file format

6 game

7 useful miscellaneous, such as macro order package

8 system maintenance and management orders

M series command

M Series - Commands for accessing DOS disks under UNIX systems.

MCD- enter the DOS subdirectory

McOpy-copy DOS file

MDEL - Delete DOS files

MDELTREE - Delete DOS Directory

MDIR- See the DOS Directory Content

MFormat - Format DOS Disk

Mlabel - adds a widget for DOS disk

MMD- Create a DOS directory

Mmove- files under DOS

MTYPE - Displays files under DOS

MREN- rename the files under DOS

MKDIR and RMDIR command

The mkdir command is created a directory, and RMDir is deleted an empty directory.

grammar:

Mkdir Directory_name

Rmdir Direcotry_name

RMDIR often replaces the RM -RF command because this command can delete an unnivated directory. Carefully use this command.

More command

More - command to read the text page by page.

More useful, you can display file content on the screen without modification.

Type: more name_of_text_file

Use the Q command to exit.

Mount, umount command

MOUNT - Install a file system.

Umount - Remove a file system.

E.g:

If you want to list the current system file system

[Test @ bluepoint /] $ mount

/ DEV / SDA1 ON / TYPE EXT2 (RW)

None ON / PROC TYPE PROC (RW)

/ dev / hda2 on / install type extra xt2 (rw)

[Test @ bluepoint /] $

MV command

MV - rename file file

MV [parameter] source file target file

MV [parameter] source file list (support wildcard) target file

E.g:

[Test @ bluepoint /] $ mv -v SourceFile Destfile

Sourcefile-> destfile

[Test @ bluepoint /] $

Passwd command

Passwd - Set the user's password

Users can use the passwd command to change their login password, usually users can only change his own password, super users can change the password of other users, superuser, and group managers can change the password, and this command can also be used To change the user's other information, such as the user's full name, the user's login shell, the user's password failure time interval, etc.

E.g:

[Test @ bluepoint /] $ passwd

New Unix Password:

Re-enter new password:

Password changed.

[Test @ bluepoint /] $

PS command PS --- Command Run Run Process.

Displayed in the screen is divided into two columns: command columns and PID columns. Command Column Displays the process name, the PID column displays the process number (stop running the program with the kill command).

Usage: ps Options

Parameter option

u provides more information

AX can recognize the process of the current user (for example, the program is running).

Reboot command

Reboot - Restart the system.

RM command

The RM command is used to delete the file.

usage:

RM file_name

The RM command accepts wildcards. The common option is: -i Inquiry before deleting determination and -r deletes all files.

E.g:

Delete all HTML files for the HTML subdirectory in the current directory.

[Test @ bluepoint /] $ rm -i /html/*.html

Warning: After the file is deleted, it cannot be recovered.

su order

Su ---- Make normal users log in with the root account.

Type the su command, the shell requires the root password. Type your password and hit the Enter key: Now enter the root account. Type EXIT (or click Ctrl D) Back to previous ordinary users.

Tar command

TAR command ---- Create and edit UNIX archive.

E.g:

Archive files with the rep / directory (and its subdirectory)

[Test @ bluepoint /] $ tar -c rep /> rep.tar

The included archive can be compressed (using Gzip or Bzip2), for example: type:

[Test @ bluepoint /] $ gzip rep.tar

To expand a archive file, type:

[Test @ bluepoint /] $ tar -xvf archive.tar

To unlock the archive file, type it;

Tar -xvf rep.tar

Or tar -xvfz rep.tar.gz (if archive is compressed using GZIP)

To find all TAR command parameters, type:

Man tar

Touch command

Touch - Time parameters for changing the file

Touch will change the access time of the file, the modification time is set to the current time of the system, if the file does not exist, establish an empty new file.

WC command

WC - Counting the number of bytes in a file, number of words, and number of lines.

WHO command

WHO - View other logged in users.

Which command

Which - the full path to the command.

Network command

Ping command

Ping Command - Determine if the machine is up to or reaches the rate

Usage: ping option IP address / domain name

E.g:

[Test @ TBLuePoint /] $ ping www.bluepoint.com.cn

Ping www.bluepoint.com.cn (202.96.162.85): 56 Data Bytes

64 bytes from 202.96.162.85:ICMP-SEQ=0 TTL = 237 TIME = 0.4ms

64 bytes from 202.96.162.85:ICMP-SEQ=1 TTL = 237 TIME = 0.4ms

64 bytes from 202.96.162.85:ICMP-SEQ=2 TTL = 237 TIME = 0.4ms

The ping command sends the size fixed packet to the other party and requires the other party to return. We can determine if the other party can be reached, whether the other party is up to date, whether it is turned on, and network delay time.

6.4 Using multiple tasks

Linux is not only a multi-user operating system, but also a multitasking operating system.

For example: You have access to the Internet and compile the program.

If you want to use the Linux system multitasking, there are two ways to be implemented.

Operating the program in the background. Simply type the & symbol after running the program. Move the background running program to the front desk to run, you need to type: fg program_name

Where program_name is a program running in the background.

Note: If you run an interactive program in the background, the program will not be able to interact.

Composed of several independent sessions.

If you can run another XTERM program or Terminal program (xtern, kvt ...) at the same time in graphics mode. In the console mode, the new wait window will appear when you press Alt F1 (to F6) at the same time. If you want to use the console mode login system in graphics mode, you need to press CTRL Alt F1 (to F6) at the same time. If you want to return to the graphics mode, you need to press CTRL Alt F7 at the same time.

6.5 Output Redirection

In order to deal with a program run, the process stores these results, the program output is redirected. For example: You want to store the command ls / binc output in file / lsbin, you can enter:

LS / bin> / lsbin

If the lsbin file already exists, the file LSBIN in the file LSBIN will be deleted after using the above command. You can use "" "to replace"> ", so that the original content of the file LSBIN will not be deleted, just the LS output. The result is appended to the LSBIN file.

Typically, when displaying files or directory content, the content is scrolling too fast on the screen, we can't read them very well. A solution is to store the command output and read it with the command more (more is a page-by-page reader).

You can type:

LS / bin> ~ / lsbin

More ~ ​​/ lsbin

Another solution is to use pipe technology. This method is to output a command to the input of another command. If you want to send the LS command to the more command, type:

LS / bin | More

LS / bin | Less

Of course, you can use different pipelines to perform complex programs.

6.6 Understanding Processes

转载请注明原文地址:https://www.9cbs.com/read-133388.html

New Post(0)