Linux 124 Lesson 1, accessing the command line

Source: Internet
Author: User

I. Introduction to the command line
The command line is a text-based interface that you can use to enter instructions into a computer system. the Linux command line is provided by a program called Shell.

When a normal user enables the shell, the default prompt end is $
Super User root runs the shell and the prompt ends with #

Computer hardware (CPU, memory, hard disk, motherboard)
Kernel (allows hardware to run efficiently and manage)
Application

The Shell is the interpreter: transforms the application commands into something that the kernel can identify and let the computer run
The Shell is the bridge between the application and the kernel

1. There are many Shell types
Cat/etc/shells See which shells the system can support
echo $shell View the system's default shell
/bin/bash Default to Bash shell

2. Shell Command classification:
Internal command kernel comes with commands
Type cd
CD is a shell builtin
After the external command has installed the software, the software comes with commands
such as type mkdir
mkdir Is/user/bin/mkdir

3. Options
(1) The short option ls-color/etc/indicates that there are multiple options-c-o-l-r
(2) long option LS--color/etc/represents an option color

Second, log in to the operating system
1. Login to operating system instructions
Ctrl+alt F2--F6 Switch to the command line virtual terminal
Ctrl+alt F1 switch to Gnome graphical interface
  
Ctrl+d or Exit command to close the current terminal window
Ctrl+shift+t New terminal window
  
Note: Strict case sensitivity in Linux
  
2. Command format

 ls           -l        /etc/                命令   选项       参数注意: 命令,必须要有   选项、参数可以互换位置

3. File type display
File command to view the type of files
Normal file [-] File
directory [d] Folder
character file [C] For example: Keyboard file Mouse file
Block device file [b] For example: Hard disk File
Socket file [s] For example: Data interface for/var/run applications
Link file [l] Shortcut
Pipe file [p] To resolve errors caused by multiple programs accessing a file at the same time

Iii. Common Commands
(1) passwd Set password
-D--delete Delete user password
-L--lock Lock user's password
-U--unlock unlocking the user's password
-e--expire set user password extended
-S--status View the user's password status
--stdin using standard input to set the password

(2) Date used to display dates and times
Date--help
  
Date +%d
Date +%y/%m/%d
Date +%x
  
When you edit a shell script, you use the date-related parameters
Date "+%y/%m/%d%h:%m:%s"

(3) Viewing the contents of a file
The head file sees the first ten lines of the file by default
head-3 file
  
Tail file By default look at the end of the file 10 lines
tail-f dynamic viewing of file contents, often used to view log file changes
  
Log file/var/log/message
Tail-f/var/log/message
  
Cat all display, more appropriate to view small files
More part of the display, can only scroll down, can not turn back
Less flip, end View Press Q launch
  
(4) WC statistics file
WC file
-C byte number
-L Number of rows
-W Number of words
  
(5) Historical History command
! 59 The 59th command in the call history
! The WC looked up from the bottom, looking for the last WC command.

CTRL + R Find History command

esc+. Automatically invoke arguments to the previous command

(6) Use of shortcut keys
Ctrl + A quickly positions the cursor to the beginning of the line
Ctrl + e Quickly positions the cursor to the end of the line
Ctrl + u Delete all content before the cursor
Ctrl + k Delete all content after cursor
Ctrl + C Cancel command
Ctrl + W Deletes a word before the cursor
  
  
Whatis passwd What's the effect of this command?
PSSSWD--help See how commands are used
Mans passwd

  
Practice:
(1) Change the student password to 123
(2) Lock student Password
(3) Display date and time as required "Yyyy-mm-dd HH:MM:SS"
(4) See how many lines are in the/etc/passwd file
(5) To view/etc/passwd file types
(6) Display the first five elements of the/etc/passwd file

Linux 124 Lesson 1, accessing the command line

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.