Quest linux-Computer Fundamentals

Source: Internet
Author: User
Tags aliases echo display time and date server memory

Computer Fundamentals and computer system composition

The computer system consists of two major parts, hardware (Hardware) and system software (software).

Second, von Neumann system

Third, the server storage type

DAS: Direct attached storage, storage directly connected to the server, similar to the server directly add a storage, with the IDE, SATA cable and other cables to connect.
NAS: Network attached storage, through the local area network, the direct implementation of file sharing on multiple servers, similar to NFS, Windows shared mode.
San: A storage area network with a SAN-based server and San client, with clients connected to the storage over the network, with a similar effect to adding a disk locally, connected by fiber or network cables.

Iv. Abi and API:

ABI: The application Binary interface, between the application and the operating system.
API: An application invokes an interface between the underlying and the operating system.

V. File system:

NTFS, FAT, iso9660
Ext2, 3, 4, centos6.x system default File system
XFS, Btrfs CentOS7 The default is XFS file system

VI. Zoning Programmes:

Mbr:
Primary partition : The number of primary partitions of a disk <=4, the system to be installed on the primary partition, if there are two disks on the server, then one of the disks can have no primary partition;
Extended partition : A disk can only have one extended partition, the number of extended partitions + the number of primary partitions <=4, the extended partition can not store data, but also to partition the logical partition;
logical partition : The logical partition number is numbered starting with 5, SDA5;
The number of primary and extended partitions can be considered specified, but the number of logical partitions inside the extended partition is automatically specified by the system;
After the partition needs to be mounted before it can be used;
Swap partition in the case of small memory, usually twice times the actual memory, but the current server memory is relatively large, the general test environment to 2G enough, the production environment of more than 8G of memory, can be divided by 10G or so enough.

Vii. Philosophy of Linux:

1. All documents;
2. Small, single-use procedures;
3, link the procedure, together to complete the complex task;
4, avoid confusing user interface;
5. The configuration data is stored in the text.

Eight, Shell type

Shell: Functions can be interpreted as translating commands into 0101 (binary) code that a computer can recognize, a translator.
Shell types : sh, csh, tcsh, ksh, bash, zsh
The shell types supported by the current system are saved in the /etc/shell configuration file

Ix. Some of the commands used

LSCPU can view the CPU information
MD5SUM/DEV/SR0 can calculate the MD5 value of the specified file
WHOAMI can show which user is currently logged in
TTY can show which terminal is currently logged in
CHVT 1-6 means using the terminal switching interface
Hostname can display the full host name
Lsb_release-a viewing version information for the current operating system
Uname-r Viewing the kernel version
Id-u can view the UID of the currently logged on user
Id-u USERNAME can view the UID of a specified user
Echo $SHELL to see the default SHELL type
Getent passwd FTP can view entries in the FTP user's/etc/passwd
Type command to see whether the specified command is an external command or an internal command
Hash can cache the path result of an external command

Ten, the relevant command detailed

CD Change Working directory
Syntax: Cd/path/to/somedir switch to the specified directory
CD Switch Home directory
CD ~ Switch back to your home directory
CD ~username switch to the home directory of the specified user (only administrators have permission to switch to other users ' home directories)
cd– switch back and forth between the last directory and the current directory
PWD is used to record the environment variables of the current working directory
OLDPWD environment variables used to record the last working directory

LS: Lists the contents of the specified directory

Syntax: ls [OPTION] ... [FILE] ...
Common options:

-a displays all files, including hidden files
-a displays except. and. All files except the
-L long format list, which represents detailed property information for displaying files
The information displayed is
-rw-r-x-1 root root 8827 October 20:34 testa.log

-rw-r-x-file type and appropriate permissions for the file
First-Represents the type of file, followed by 9-bit representation of the appropriate permissions

File type: the
-: Indicates an ordinary file,
D: Indicates a directory
B: Represents a block device file that supports random access in "block" units
C: Represents a character device file that supports linear access in "character" units
L: Indicates a symbolic link (soft link) file
P: Indicates pipeline file, pipe file with name
S: Indicates a socket file
1 indicates the number of times a file has been hard-linked
Root indicates the owner of the file
Root represents a group of files
8827 indicates the size of the file
But if the ll/dev is showing two numbers, like BRW-RW —-. 1 root cdrom 11, 0 July 00:34 sr0
Here the number before one represents the main device number, the latter represents the secondary device number, one identifies the device type, the latter identifies the same class of different devices
October 15 20:34 Indicates the last time the file was modified
-H indicates a unit conversion of the file size, the converted result may be a non-accurate value (difference between 1000 and 1024)
-d means to display only the directory itself, not the properties of each file below the directory, to be used with-l to display the property information of the directory itself
-R, –reverse indicates the display is displayed in reverse order, the default is ascending display
-R, –recursive indicates recursive display
Cat: Display the file contents of a text file
Syntax: Cat [OPTION] ... [FILE] ...
Options:
-N to the displayed text line number
-e display line terminator, Linux line terminator is $
File can have more than one file, when it is displayed, all the files are listed.

echo: Echoing command  
Syntax: echo [OPTION] ... [string]... 
option:  
-n display does not automatically wrap   after completion;
-E enables the signifier to take effect instead of showing  
Tilde: \ n = line break

1.    \b  means backspace 
2.   \t means tab
3.   \0nnn insert nnn (octal) represents the ASCII encoding

Using the above can be changed color, color profile in/etc/dir_colors

ECHO-E "\033[background color, font color m string \033[0m" background color can be omitted
Echo-e "\033[43;31m Nihao \033[0m"
43;31 represents the foreground and background colors
Font color: 30-37: Black, red, green, yellow, blue, violet, sky blue, white
Background color: 40-47: Black, red, green, yellow, blue, purple, sky blue, white
\033[0m is the control option, 0m for no attributes, 1m for high brightness, 4m for underscores, 5m for flashing, 7m for reverse, 8m for hidden display
Echo-e "\033[5m\033[44;32m*\033[0m" appears as the * number flashes, if written to the last face \033[0m here, it will become the display after the completion of the command prompt flashing after the line
STRING: can use quotation marks, both single and double quotation marks can be used
Single quotes: Strong references, variable references do not perform substitutions;
Double quotes: Weak references, variable references perform substitutions;
such as: echo "SHELL '
The information displayed isUser result is echo root
Echo ' EchoUSER
echo "Echo $USER" results for Echo Root
Echoecho $USERResult is root
Note: The normal reference notation in a variable reference is ${shell}, but many times {} can be omitted

Shutdown: Shutdown or restart command
Syntax: Shutdown [OPTIONS ...] [TIME] [WARNING ...]
Options:
-H: Indicates shutdown
-R: Indicates restart
-C: To cancel the shutdown or restart operation that was previously defined
Time:
Now: Table immediately
HH:MM represents a specified point in time
+m indicates how many minutes after the current moment
WARNING: Indicates a prompt message
Example: Shutdown-r +10 "System is going-reboot after minutes"
Date-related commands: date, clock, Hwclock, Cal
Linux has two sets of time, one set is the hardware clock, the system clock, the system starts from the hardware to read the date and time information; After the reading is done, it is not related to the hardware
Date: Displays or sets the system time (displays and sets the system clock)
Syntax: Date [OPTION] ... [+format] used to display time and date
Date [MMDDHHMM[[CC]YY][.SS]] to set the time date
Date-d "string": Displays the date of the specified string
Example: date-d yesterday
Date-d "days ago" shows the date 10 day ago
date-d "1 month ago" Showing 1 months 10 days ago Date
Date-d "Days" displays the date after 20 day
Date–set 20160725 You can set the date to July 25, 2016
Date–set "20160726 17:25:26" to set the date and time
+format: Represents a date displayed as a specified format, plus a fixed format
The common formats supported by format are:
%F: Displayed as a date format for example 2016-07-20
%T: Displays a time display format such as 08:58:15
%Y: Show year
%M: Show Month
%d: Display Day
%H: Show several points
%M: Show a few
%s: Display for a few seconds
%j: Displays the number of days in the current year, with a value of 1-356
%d: Displayed as 07/22/16 such as month/day/year format
%s: Displays the timestamp, which is the number of seconds from January 1, 1970 0:0 0 seconds to the current time
Multiple formats are separated by spaces, and the entire format can be enclosed in double quotation marks
Example: Date + "%F%T"
Example: Date + "%y%m%d%h%m%s"
Date + "Year:%y month:%m"
Example of setting the time:
Date 072008522016.25 Indicates the modification time is July 20 08:52 2016 25 seconds

Clock,hwclock: Query and set hardware clock (hardware clock, can be understood as BIOS clock)
Clock and Hwclock for the same set of commands, clock is the hard link of hwclock
Clock does not follow any information, indicating that the hardware clock is displayed
-s,–hctosys indicates that the system time is set to the same time as the hardware time
-W,–SYSTOHC indicates that the hardware time is set to the same time as the system time
Cal: Show Calendar
Cal indicates that the current month's calendar is displayed
Cal 2016 represents the year-round calendar that displays the specified year
Cal 07 2016 indicates a calendar that displays the specified month of the specified year

Type: Displays the types of commands, whether they are built-in or external commands
Example: Type ls
If the original command is hidden and you want to use the original command, you can use the \ls

Whatis command can show the approximate function description of the commands

Which: the full path used to display the command
Syntax: which [OPTION] ... COMMAND
Example: Which LS
Options:
–skip-alias ignores command aliases and directly displays the command itself

whereis: Displays the path to the command and the path information for the associated Help file  
Syntax: Whereis [options] name 
For example: Whereis ls 
Options:  
- b displays only the path of the binary program  
-M only displays the path to the Help file's program  
who: Shows which logged-on users   the system today;
Syntax: who [options]... 
Displays information for all logged-in users of the current system  
who displays information   for all logged-in users of the current system;
Who-b Displays the time   the system started,
Who-r shows the time the system started, and the current system RunLevel  
Who-d Displays information   the system's death process;
Who-u displays information for each logged-on user, including the process number   that shows the login duration and login, and
W: Enhanced who command to display all currently logged-in users. and its actions in the action, and more information

command alias:  
alias can display command alias information on the current system  
Define command aliases:  
alias name= ' command ' is valid only for the current shell, effective immediately, fails after reboot  
For example alias cds= ' cd/etc/sysconfig/network-scripts/'  
Revoke alias:  
Umalias name 
For example Unalias cds 
Hash Command: You can cache the path of a command into memory  
Hash to view the list of cached  
hash-d command You can delete an entry with command in the hash cache  
Hash-r can empty the cache table of the hash path cache

Screen command: The character interface enables Remote Assistance (provided that you connect to the same machine, use the same account) and need to install the software, yum install
Open a new Shared desktop: The name of the Screen-s shared session
Show list of shared desktop sessions: Screen-ls
Connecting to a shared session established: Screen-x Session Name
Exit Session Ctrl+a,d
The process number of the Screen-r session is connected again after exiting
Exit and close the session completely exit
When you log in remotely, run a program that executes longer (such as a backup), in order to prevent the network from being disconnected,
Program disconnected, unable to know the state of the program running, you can open a screen to run the program
Command execution Priority: command alias > Internal > External Command Cache (hash) > External command

Xi. homework After class

1, with echo display flashing, color inverted triangle  
echo-e \033[background color; font Color m string \033[0m "background color can be omitted  
echo-e" \033[43;31m Nihao \033[ 0m "&NBSP;
43;31 represents the foreground and background color  
Font color: 30-37 respectively: Black, red, green, yellow, blue, purple, sky blue, white  
Background color: 40-47 respectively: Black, red, green, yellow, blue, purple, Sky, White  
\033[0m is a control option, 0m for no attributes, 1m for high brightness, 4m for underscores, 5m for flashing, 7m for reverse, 8m for hidden display  
Echo-e "\033[5m\033[44;32m*\ 033[0m "Display as * number flashing, if you write to the last face \033[0m here, it will become the display after the completion of the line after the command prompt flashing, so you can:

1.  [[email protected] ~] 

2, date displays the date before 10 days, and the last 20 days of the day information
Date-d "Day Ago" +%f show 10 days ago Date
Date-d "Days" +%f display date after 20 day

3, Screen command: The character interface for Remote Assistance (provided that: connected to the same machine, using the same account) need to install the software, yum install
Open a new Shared desktop: The name of the Screen-s shared session
Show list of shared desktop sessions: Screen-ls
Connecting to a shared session established: Screen-x Session Name
Exit Session Ctrl+a,d
The process number of the Screen-r session is connected again after exiting
Exit and close the session completely exit
When you log in remotely, run a program that executes longer (such as a backup), in order to prevent the network from being disconnected,
Program disconnected, unable to know the state of the program running, you can open a screen to run the program


Quest linux-Computer Fundamentals

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.