Introduction to Linux and Ubuntu installation
Common directives
System administration Commands
Packaging compression-related commands
Shut down/Restart the machine
Linux Pipelines
Linux Package Management
Vim use
User and User group management
File Rights Management
Daniel Notes-www.weixuehao.com
From: HTTP://WWW.WEIXUEHAO.COM/ARCHIVES/25
Introduction to Linux and Ubuntu installation
Linux, free open source, multi-user multitasking system. Linux is based on multiple versions of the derivative. RedHat, Ubuntu, Debian
Install a VMware or VirtualBox virtual machine. Specific installation procedures, to find Baidu.
Install Ubuntu again. Specific installation procedures, to find Baidu.
After installation, you can see the directory structure of the Linux system, see link http://www.cnblogs.com/laov/p/3409875.html
Common directives
LS Display file or directory
-l list File details L (list)
-a lists all files and directories under the current directory, including Hidden A (all)
mkdir Creating a Directory
-P Create directory, if no parent directory, create p (parent)
CD Switch Directory
Touch creates an empty file
Echo creates a file with content.
Cat View File Contents
CP Copy
MV Move or rename
RM Delete File
-R Recursive Delete, can delete subdirectories and files
-F Force Delete
Find searches a file system for a file
WC statistics Text line number, word count, number of characters
Grep finds a string in a text file
RmDir Delete Empty Directory
Tree structure display directory, need to install tree package
PWD Displays the current directory
LN creates a linked file
More, less pagination displays text file contents
Head, tail display file header, tail content
CTRL+ALT+F1 command line full-screen mode
System administration Commands
Stat Displays details of the specified file, more detailed than LS
Who shows online login
WHOAMI Show current Operation user
Hostname Display host name
Uname Display System Information
Top dynamic display currently consumes the most resources process information
PS Display transient process status Ps-aux
Du view directory size Du-h/home with units display directory information
DF View disk size df-h with unit display disk information
Ifconfig Viewing network conditions
Ping Test network connectivity
Netstat Displaying network status information
Man command won't work, find men like: Guy ls
Clear Clear Screen
Alias renamed the Command as: Alias showmeit= "Ps-aux", in addition to de-use Unaliax Showmeit
Kill kills the process, you can first view the process ID with the PS or Top command, and then kill the process with the kill command.
Packaging compression-related commands
Gzip:
BZIP2:
Tar: Packaging compression
-C Archive File
-X Compressed file
-Z gzip Compressed file
-j bzip2 Compressed Files
-V shows the compression or decompression process V (view)
-F Use file name
Cases:
TAR-CVF/HOME/ABC.TAR/HOME/ABC only packaged, not compressed
TAR-ZCVF/HOME/ABC.TAR.GZ/HOME/ABC packaged and compressed with gzip
TAR-JCVF/HOME/ABC.TAR.BZ2/HOME/ABC packaged and compressed with bzip2
Of course, if you want to decompress, just replace the above command TAR-CVF/TAR-ZCVF/TAR-JCVF "C" in the "X".
Shut down/Restart the machine
Shutdown
-R shutdown Restart
-H shutdown does not restart
Now turn the machine off.
Halt shut down the machine
Reboot restart
Linux Pipelines
Use the standard output of one command as the standard input for another command. That is, the combination of several commands to use, the latter command in addition to the results of a previous command.
Example: Grep-r "Close"/home/* | More in the home directory to find all files, including close files, and paging output.
Linux Package Management
Dpkg (Debian package) management tool with a. deb suffix. This approach is suitable for systems that are not networked.
For example, install the tree command installation package, first upload tree.deb to the Linux system. Then install it using the command below.
sudo dpkg-i tree_1.5.3-1_i386.deb installation software
sudo dpkg-r tree Uninstall software
Note: There are several ways to upload tree.deb to a Linux system. Vmwaretool, use of Mount mode, use of WINSCP tools, etc.;
APT Advanced Packaging Tool. This method is suitable for the system to be able to connect the internet situation.
Still take tree as an example
sudo apt-get install tree
sudo apt-get remove tree unload tree
sudo apt-get update software
sudo apt-get upgrade
Convert. rpm files to. deb files
. RPM is the software format used by Redhat. cannot be used directly under Ubuntu, so you need to convert it.
sudo alien abc.rpm
Vim use
Vim three modes: Command mode, insert mode, edit mode. Use ESC or I or: to toggle the mode.
Command mode:
: Q exit
: q! Force exit
: Wq Save and exit
: Set number Displays line numbers
: Set Nonumber hidden line number
/apache find Apache in the document press N to jump to the next, Shift+n previous
YYP Copy the cursor line, and paste
H (move left one character ←), J (next line ↓), K (previous line ↑), L (move right one character →)
User and User group management
/etc/passwd Storing user accounts
/etc/group Storage Group Account
/etc/shadow Store password for user account
/etc/gshadow Password to store user group account
Useradd User Name
Userdel User Name
AddUser User Name
Groupadd Group Name
Groupdel Group Name
passwd root sets the password for root
Su Root
Su-root
/etc/profile System Environment variables
Bash_profile User Environment variables
. BASHRC User Environment variables
SU user switches the user and loads the configuration file. bashrc
Su-user switch User, load configuration file/etc/profile, load Bash_profile
User and user groups for changing files
sudo chown [-r] Owner[:group] {file| Directory}
For example: Also take jdk-7u21-linux-i586.tar.gz as an example. belongs to user Hadoop, group Hadoop
You want to switch the users and groups to which this file belongs. You can use commands.
sudo chown root:root jdk-7u21-linux-i586.tar.gz
File Rights Management
Three basic permissions
R read value represented as 4
The W write value is represented as 2
X executable value represented as 1
, the permissions for the jdk-7u21-linux-i586.tar.gz file are-rw-rw-r--
-rw-rw-r--altogether 10 characters, divided into four segments.
The first character "-" indicates a normal file, and the "L" link may also appear in this location; "D" means the directory
The No. 234 character "rw-" represents the permissions of the currently owned user. So the value is expressed as 4+2=6
The No. 567 character "rw-" represents the permissions for the group that is currently owned. So the value is expressed as 4+2=6
The No. 890 character "r--" represents other user rights. So the value is represented as 2
So the permission to manipulate this file is represented by a value of 662
Change permissions
sudo chmod [u belongs to user g belongs to group O Other User a All users] [+ Increase permissions-reduce permissions] [r W x] directory name
For example: There is a file filename, the permission is "-rw-r----x", the permission value is changed to "-rwxrw-r-x", with a numeric representation of 765
sudo chmod u+x g+w o+r filename
The above example can be represented by a numerical value
sudo chmod 765 filename
Xshell 5 (Build 0719)
Copyright (c) 2002-2015 Netsarang Computer, Inc. All rights reserved.
Type ' help ' to learn. Xshell prompt.
[c:\~]$
Connecting to 192.168.170.40:22 ...
Connection established.
To escape to local shell, press ' ctrl+alt+] '.
Last Login:tue 11 04:15:21 2015
[Email protected] ~]# Mono-l:/tmp/server.lock/usr/src/liaotian/easychat_server.exe
Unknown command line option: '-l:/tmp/server.lock '
[Email protected] ~]# mono-s
Mono-service Mono-service2 Mono-sgen mono-sgen-gdb.py Mono-shlib-cop
[Email protected] ~]# Mono-service-l:/tmp/server.lock/usr/src/liaotian/easychat_server.exe
[Email protected] ~]# Ps-aux | grep Mono
Root 1827 6.6 1.4 377960 27652 pts/0 Sl 03:50 0:00/usr/bin/mono/usr/lib/mono/4.5/mono-service.exe-l:/tmp/server.lock/u Sr/src/liaotian/easychat_server.exe
Root 1832 0.0 0.0 112656 988 pts/0 r+ 03:50 0:00 grep--color=auto Mono
[Email protected] ~]# lsof-i:8888
-bash:lsof: Command not found
[Email protected] ~]# yum-y install lsof
Loaded plugins: Fastestmirror
Repodata is over 2 weeks old. Install Yum-cron? Or Run:yum Makecache Fast
Base | 3.6 KB 00:00:00
Extras | 3.4 KB 00:00:00
Mono | 2.9 KB 00:00:00
Updates | 3.4 KB 00:00:00
(1/3): extras/7/x86_64/primary_db | KB 00:00:00
(2/3): mono/primary_db | 328 KB 00:00:02
(3/3): updates/7/x86_64/primary_db | 3.3 MB 00:00:03
Determining fastest Mirrors
* Base:mirrors.btte.net
* Extras:mirrors.btte.net
* Updates:mirrors.btte.net
Resolving dependencies
--Checking transactions
---> Package lsof.x86_64.0.4.87-4.el7 will be installed
--Resolve dependency completion
Dependency resolution
=============================================================================================================== =================
Package schema version Source size
=============================================================================================================== =================
Installing:
Lsof x86_64 4.87-4.EL7 Base 331 k
Transaction summary
=============================================================================================================== =================
Installing the 1 package
Total Downloads: 331 k
Installation Size: 927 K
Downloading packages:
lsof-4.87-4.el7.x86_64.rpm | 331 KB 00:00:00
Running transaction Check
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Installing: lsof-4.87-4.el7.x86_64 1/1
Verified in: lsof-4.87-4.el7.x86_64 1/1
has been installed:
Lsof.x86_64 0:4.87-4.EL7
Finished!
[[email protected] ~]# lsof-i:8888
COMMAND PID USER FD TYPE DEVICE size/off NODE NAME
Mono 1827 root 6u IP V4 17960 0t0 TCP localhost:ddi-tcp-1 (LISTEN)
[[email protected] ~]# ps-aux | grep mono
Root 1827 0.7 1.4 5113 27652 pts/0 Sl 03:50 0:00/usr/bin/mono/usr/lib/mono/4.5/mono-service.exe-l:/tmp/server.lock/usr/src/liaotian/ Easychat_server.exe
Root 1872 0.0 0.0 112656 988 pts/0 r+ 03:51 0:00 grep--color=auto Mono
[[email protected] ~]# kill 1827
[[email protected] ~]# ps-aux | grep mono
Root 1874 0.0 0.0 112656 988 pts/0 r+ 03:52 0:00 grep --color=auto mono
[[email protected] ~]# mono/usr/src/liaotian/easychat_server.exe
Server started, listening ...
Log4net:error Xmlhierarchyconfigurator:cannot Find Property [Rollingstyle] To set object on [Log4net. Appender.fileappender]
Log4net:error Xmlhierarchyconfigurator:cannot Find Property [Datepattern] To set object on [Log4net. Appender.fileappender]
2015-09-01 03:52:38,487 [DEBUG] [class:listener][method:startup][business]
Server is started, listening ...
Server ip:192.168.170.40 port number: 8888
2015-09-01 03:52:38,494 [DEBUG] [class:listener][method:startup][business]
Server ip:192.168.170.40 port number: 8888
^c
[Email protected] ~]# Ps-aux | grep Mono
Root 1880 0.0 0.0 112656 988 pts/0 r+ 03:53 0:00 grep--color=auto Mono
[Email protected] ~]# Systemctl stop Firewalld
[Email protected] ~]# systemctl disable FIREWALLD
[Email protected] ~]# Setenforce 0
[Email protected] ~]# Vi/etc/selinux/config
[Email protected] ~]# Vi/etc/sysconfig/iptables
[Email protected] ~]# ls-a/etc/sysconfig/iptables
/etc/sysconfig/iptables
[Email protected] ~]# ls-a/etc/sysconfig/
. Cpupower init. IPTABLES.SWM kdump Network Run-parts
.. Crond ip6tables. IPTABLES.SWN kernel network-scripts SELinux
Authconfig ebtables-config ip6tables-config. Iptables.swo man-db Rdisc sshd
CBQ firewalld iptables. IPTABLES.SWP Modules Readonly-root Wpa_supplicant
Console Grub Iptables-config irqbalance netconsole Rsyslog
[Email protected] ~]# RM-RF. iptab*
[Email protected] ~]# ls-a/etc/sysconfig/
. Cpupower init. IPTABLES.SWM kdump Network Run-parts
.. Crond ip6tables. IPTABLES.SWN kernel network-scripts SELinux
Authconfig ebtables-config ip6tables-config. Iptables.swo man-db Rdisc sshd
CBQ firewalld iptables. IPTABLES.SWP Modules Readonly-root Wpa_supplicant
Console Grub Iptables-config irqbalance netconsole Rsyslog
[Email protected] ~]# rm-rf/etc/sysconfig/.iptab*
[Email protected] ~]# ls-a/etc/sysconfig/
. Console firewalld ip6tables-config kdump netconsole readonly-root sshd
.. Cpupower Grub iptables Kernel network Rsyslog wpa_supplicant
Authconfig crond init iptables-config man-db network-scripts run-parts
CBQ ebtables-config ip6tables irqbalance modules Rdisc SELinux
[Email protected] ~]# Vi/etc/sysconfig/iptables
[Email protected] ~]# Mono/usr/src/liaotian/easychat_server.exe
Server is started, listening ...
Log4net:error Xmlhierarchyconfigurator:cannot Find Property [Rollingstyle] To set object on [Log4net. Appender.fileappender]
Log4net:error Xmlhierarchyconfigurator:cannot Find Property [Datepattern] To set object on [Log4net. Appender.fileappender]
2015-09-01 03:55:12,978 [DEBUG] [class:listener][method:startup][business]
Server is started, listening ...
Server ip:192.168.170.40 port number: 8888
2015-09-01 03:55:12,986 [DEBUG] [class:listener][method:startup][business]
Server ip:192.168.170.40 port number: 8888
2015-09-01 03:56:59,600 [DEBUG] [class:listener][method:startup][business]
[System message] new user Steven on 2015/9/1 3:56:59 connected ... Current online Visitors: 1
[System message] new user Steven on 2015/9/1 3:56:59 connected ... Current online Visitors: 1
^c
Introduction to Linux and Ubuntu installation