Write while reading. 1. create a user useradd-m-d/home/tomtom-Goracle-m to create a home directory for the user, and copy the files in/etc/skel for initialization. -G indicates joining a user group. The user's default settings are stored in/etc/defa...
Write while reading.
1. create a user
Useradd-m-d/home/tom-G oracle
-M: create a home directory for the user and copy the files in/etc/skel to initialize the directory. -G indicates joining a user group.
The user's default settings are stored in the/etc/default/useradd file. you can use useradd
-D command to view or modify these configurations. Contains the default group, SHELL, skel, user default Expiration Time (EXPIRE), the number of days after the password expires (INACTIVE ).
Useradd-D-s shel-B path/to/default/home-e date-f days-g group
2. password validity period:
Chage-M 30 tom sets the password validity period. you must change the password after 30 days.
If no parameter is specified, the interactive setting mode is enabled.
3. user control
Passwd-l tom locks the user. tom cannot use the password to log on to the system. However, you can log on to the system through a public key mechanism such as ssh. Use passwd-u tom to unlock.
You can use the following methods to completely disable user logon:
Usermod -- expiredate 1 (set the user's expiration date to 1970, 01, and 01. This value is 1 of the UNIX time)
Or change the logon SHELL to/bin/false.
Usermod-s/bin/false
4. SHELL environment variables
PS1 standard prompt symbol: usually used:
[\ U @ \ h \ W] \$ ==> [user name @ host name current directory] #==> [root @ OA01 work] #
In addition, \ T indicates the time. \ D date.
5. system guiding process:
BIOS = & gt; MBR = & gt; GRUB = & gt; stage 1 \ stage 1.5 \ stage
2. now we can see the boot menu item => GRUB looks for the kernel binary code and loads initd to the memory. imgfile (contains the driver loaded by the kernel to use the host hardware ). after loading, GRUB gives control to the kernel
=> The kernel calls the init Program to initialize the operating system and services.
Init configuration file/etc/inittab:
REDHAT running level:
#0-halt (Do NOT set initdefault to this)
#1-Single user mode
#2-Multiuser, without NFS (The same as 3, if you do not have networking)
#3-Full multiuser mode
#4-unused
#5-X11
#6-reboot (Do NOT set initdefault to this)
Id: 5: initdefault: # if you do not start GHI, change 5 to 3.
Init uses the following scripts to manage services and running levels:
/Etc/rc. d/rc. sysinit
/Etc/rc. d/rc. local
[Root @ OA01 rc. d] # ls-l
Drwxr-xr-x 2 root 4096 2007-10-31 init. d
-Rwxr-xr-x 1 root 2352 rc
Drwxr-xr-x 2 root 4096 2011-04-26 rc0.d
Drwxr-xr-x 2 root 4096 2007-10-31 rc1.d
Drwxr-xr-x 2 root 4096 2007-12-17 rc2.d
Drwxr-xr-x 2 root 4096 2010-08-11 rc3.d
Drwxr-xr-x 2 root 4096 2010-08-11 rc4.d
Drwxr-xr-x 2 root 4096 2010-08-17 rc5.d # script corresponding to the running level
Drwxr-xr-x 2 root 4096 2007-10-31 rc6.d
-Rwxr-xr-x 1 root 367 rc. local
-Rwxr-xr-x 1 root 27866 rc. sysinit
[Root @ OA01 rc5.d] # ls
K01tog-pegasus K50netdump S05openibd S44acpid
K02cups-config-daemon K50tux S06cpuspeed S55sshd
K02NetworkManager K50vsftpd S08iptables S56rawdevices
K05saslauthd K73ypbind S10network S56xinetd
K10cups K74nscd S12syslog S85gpm
K10dc_server K74ntpd S13irqbalance S87iiim
K10psacct K85mdmpd S13iscsi S90crond
K12dc_client K87auditd S13portmap S90xfs
K15httpd K89netplugd S14nfslock S91smb
K20nfs K90bluetooth S15mdmonitor S95anacron
K24irda K91isdn S18rpcidmapd S95atd
K25squid K94diskdump S19rpcgssd S96readahead
K30sendmail K96ipmi S25netfs S97messagebus
K30spamassassin K96pcmcia S26apmd S97rhnsd
K35vncserver S00microcode_ctl S26lm_sensors S98haldaemon
K35winbind S04readahead_early S28autofs S99local
K50ibmasm S05kudzu S40smartd
The script starting with S is the service startup script, followed by two digits in the running order, followed by the service name.
K corresponds to the service closing script.
Restart a service mysqld stop & service mysqld start
Manage these services. RH has the chkconfig command. UBUNTU turned off the service with a invoke-rc.d, update-rc.d management service, and the sysv-rc-conf GUI (additional installation required ).
UNBUNTU uses the Upstart method to replace the SysV standard
6. crontab
00 ***/ftproot/transfer. sh
Minute Hour date month week execute command
The crontab of each user is in/var/spool/cron/$ uid. Remember that the crontab of the system is different from the crontab of every user !!
In addition, you can use/etc/crontab in LINUX to store the scheduled configuration of the system. the file content is as follows:
SHELL =/bin/bash
PATH =/sbin:/bin:/usr/sbin:/usr/bin
MAILTO = root
HOME =/
# Run-parts
01 *** root run-parts/etc/cron. hourly
02 4 *** root run-parts/etc/cron. daily
22 4 ** 0 root run-parts/etc/cron. weekly
42 4 1 ** root run-parts/etc/cron. monthly
The host has a service process responsible for executing these tasks: crond
7. view (or modify) the status and configuration of all network interfaces in ifconfig. Eth0 indicates the first Nic.
Configuration File: RH:/etc/sysconfig/network-scripts UNBUNTU:/etc/networks
UBUNTU can directly modify/etc/networks/interfaces to configure the network.
Route: route
Network Monitoring: ping tcpdump mt nc dig iptables
Firewall: RH: system-config-security UBTUNTU: ufw
Remember a command: ufw allow 80/tcp enables the permission to access port 80 through tcp.
Configure the firewall tool: shorewall
Tcp wrappers important files/etc/hosts. allow priority>/etc/hosts. deny
8-pack management
RH: rpm YUM
UBUNTU: aptitude dpkg
Yum search nmap & yum install nmap & yum check-update & yum
Remove nmap & yum info kernel & yum clean all
Configuration file/etc/yum. conf/etc/yum. repos. d/status file/var/lib/yum/var/cache/yum
UBUNTU apt-get install xxx
9 Storage Management
Partition fdisk/dev/sda & fdisk/dev/sdb
File system EXT3 EXT4 XFS JFS
Create a file system mkfs. ext3 mkfs. ext4 mkfx. vfat
Adjust the file system parameter tune2fs
A command dmesg checks the device node through the kernel
USB flash drive: dmesg | grep sd
Mount the file system
Mount-t ext3/dev/sdb1/mnt/data
Lsof/mnt/data to check which processes are reading and writing a file system
File system configuration file automatically mounted by the system/etc/fstab
Check File system utilization df-h & df-sh *
* *** RAID
Create raid1 with backup
Mdadm -- create/dev/md0 -- level = raid1 -- raid-devices = 2/dev/sdb1/dev/sdc1
-- Spare-devices = 1/dev/sdd1
Configuration File:/etc/mdadm. conf/etc/mdaadm. conf
* ***** Logical volume
Dd if =/dev/zero of =/dev/sdg bs = 512 count = 1
Pvcreate/dev/md0
Pvs
Vgs
Lvs
Vgextend ubuntu-au-mel-1/dev/md0
Au-mel-ubuntu-1/dev/md0 vgreduce
Vgcreate raid-volumn/dev/md0
Lvcreate -- name www -- size 2G raid-volumn
Mkfs. ext3/dev/raid-volumn/www
# Edit fstab to define the loading point
Mount/srv/www
Lvextend -- size + 2G/dev/raid-volumn/www
LVM manages file systems in a much more complex way than a zone, but it is much more flexible to use.
This article is from the author of the blog Park, Yu head, and Ping