whoami-----------谁在登陆
[root@VM_226_140_centos ~]# whoami
root
Who---------------查看全部用户
[root@VM_226_140_centos ~]# who
root tty1 Mar 15 09:17
root pts/0 Mar 19 21:19 (27.19.88.163)
Who am i-------------查看当前终端
[root@VM_226_140_centos ~]# who am i
root pts/0 Mar 19 21:19 (27.19.88.163)
W -------------获取大量信息,启动时间,登陆用户,1分钟提交任务。。。。。等
[root@VM_226_140_centos ~]# w
21:23:12 up 17 days, 4:14, 2 users, load average: 0.00, 0.02, 0.00
USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT
root tty1 - Wed09 4days 0.01s 0.01s -bash
root pts/0 27.19.88.163 21:19 0.00s 0.00s 0.00s w
Users ----------目前登陆使用的终端
[root@VM_226_140_centos ~]# users
root root
tty--------------终端控制
[root@VM_226_140_centos ~]# tty
/dev/pts/0
Uname---------操作系统
[root@VM_226_140_centos ~]# uname
Linux
Uname -n------主机名
[root@VM_226_140_centos ~]# uname -n
VM_226_140_centos
Uname -i-------处理器
[root@VM_226_140_centos ~]# uname -i
x86_64
uname -r-------系统版本
[root@VM_226_140_centos ~]# uname -r
2.6.32-504.30.3.el6.x86_64
Uname –s-------操作系统名字
[root@VM_226_140_centos ~]# uname -s
Linux
Uname –p------处理器类型-------怀疑腾讯给的假服务器
[root@VM_226_140_centos ~]# uname -p
x86_64
uname -m--------硬件名称-------怀疑腾讯给的假服务器
[root@VM_226_140_centos ~]# uname -m
x86_64
uname -a-------全部信息
[root@VM_226_140_centos ~]# uname -a
Linux VM_226_140_centos 2.6.32-504.30.3.el6.x86_64 #1 SMP Wed Jul 15 10:13:09 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux
Whatis 【命令】-------帮助
[root@VM_226_140_centos ~]# whatis ls
ls (1) - list directory contents
【命令】--help---------帮助
[root@VM_226_140_centos ~]# su --help
Usage: su [OPTION]... [-] [USER [ARG]...]
Change the effective user id and group id to that of USER.
-, -l, --login make the shell a login shell,
clears all envvars except for TERM,
initializes HOME, SHELL, USER, LOGNAME and PATH
-c, --command=COMMAND pass a single COMMAND to the shell with -c
--session-command=COMMAND pass a single COMMAND to the shell with -c
and do not create a new session
-f, --fast pass -f to the shell (for csh or tcsh)
-m, --preserve-environment do not reset HOME, SHELL, USER, LOGNAME
environment variables
-p same as -m
-s, --shell=SHELL run SHELL if /etc/shells allows it
--help display this help and exit
--version output version information and exit
A mere - implies -l. If USER not given, assume root.
Report su bugs to bug-coreutils@gnu.org
GNU coreutils home page: <http://www.gnu.org/software/coreutils/>
General help using GNU software: <http://www.gnu.org/gethelp/>
Report su translation bugs to <http://translationproject.org/team/>
For complete documentation, run: info coreutils 'su invocation'
date -------时间
[root@VM_226_140_centos ~]# date
Sun Mar 19 21:41:30 CST 2017
Cal --------显示全部
[root@VM_226_140_centos ~]# cal
March 2017
Su Mo Tu We Th Fr Sa
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31
Clear-------清除屏幕
[root@VM_226_140_centos ~]#
Su root ----切换用户
[root@VM_226_140_centos ~]# su lai
[lai@VM_226_140_centos root]$
Passwd--------修改密码
Passwd 【用户名】-------修改该用户密码
[root@VM_226_140_centos ~]# passwd lai
Changing password for user lai.
New password: 【密码】
BAD PASSWORD: it does not contain enough DIFFERENT characters
Retype new password: 【再次输入密码】
passwd: all authentication tokens updated successfully.
Useradd 【用户名】-------------------增加用户
[root@VM_226_140_centos ~]# useradd lai
[root@VM_226_140_centos ~]#
Userdel 【删除的用户】
[root@VM_226_140_centos ~]# cat /etc/passwd
~~~~~~~此处省略一万行~~~~~~
mysql:x:500:500::/home/mysql:/bin/bash
lai:x:501:501::/home/lai:/bin/bash
[root@VM_226_140_centos ~]# userdel lai
[root@VM_226_140_centos ~]# cat /etc/passwd-------查看用户状态
root:x:0:0:root:/root:/bin/bash
~~~~~~~此处省略一万行~~~~~~
mysql:x:500:500::/home/mysql:/bin/bash-------可见lai用户已经被删除
man----手册使用,了解命令功能
[root@VM_226_140_centos man]# man ls
【1表示ls在手册第一章】
LS(1) User Commands LS(1)
NAME
ls - list directory contents
SYNOPSIS
ls [OPTION]... [FILE]...
~~~~~~~此处省略一万行~~~~~~
-c with -lt: sort by, and show, ctime (time of last modification of file status information) with -l: show ctime and sort by name otherwise: sort by ctime
:
退出方法!后Enter
Man具体位置在usr/share/man
pwd---------确定现在位置
[root@VM_226_140_centos home]# pwd
/home
Cd ..------返回上一级 -------本来不准备演示的,和windows相同
[root@VM_226_140_centos home]# cd ..
[root@VM_226_140_centos /]# ls
bin boot data dev etc home lib lib64 lost+found media mnt opt proc root sbin selinux srv sys tmp usr var
ls -l /media--------查看当前挂载项目
[root@VM_226_140_centos /]# ls -l /media
total 0
ls –a -------隐藏文件查看
[root@VM_226_140_centos /]# ls -a
. .. .autofsck .autorelabel bin boot data dev etc home lib lib64 lost+found media mnt opt proc root sbin selinux srv sys tmp usr var
ls -l-------细节文件查看
[root@VM_226_140_centos /]# ls -l
total 104
dr-xr-xr-x. 2 root root 4096 Mar 3 2016 bin
dr-xr-xr-x. 4 root root 4096 Mar 3 2016 boot
~~~~~~~此处省略一万行~~~~~~
drwxr-xr-x. 13 root root 4096 Dec 25 2014 usr
drwxr-xr-x. 19 root root 4096 Mar 3 2016 var
ls -h---------查看文件大小
[root@VM_226_140_centos /]# ls –s
total 104
4 bin 4 boot 4 data 0 dev 4 etc 4 home 4 lib 12 lib64 20 lost+found 4 media 4 mnt 4 opt 0 proc 4 root 12 sbin 4 selinux 4 srv 0 sys 4 tmp 4 usr 4 var
Cp 【源文件】 【新文件】 -----复制(-r复制文件夹解决方式)
cp -r dir1/. dir2 -----如果文件夹存在,则用这种方法,会询问覆盖信息(cp -rf也是这样)
cp -rif a/b/* a1/b1/回车 -----整个文件夹的文件复制,无提示
anaconda-ks.cfg install.log install.log.syslog mysql-5.6.26-linux-glibc2.5-x86_64 mysql-5.6.26-linux-glibc2.5-x86_64.tar.gz wget-log wget-log.1
[root@VM_226_140_centos ~]# cp mysql-5.6.26-linux-glibc2.5-x86_64.tar.gz mysql.gz
[root@VM_226_140_centos ~]# ls
anaconda-ks.cfg install.log install.log.syslog mysql-5.6.26-linux-glibc2.5-x86_64 mysql-5.6.26-linux-glibc2.5-x86_64.tar.gz mysql.gz wget-log wget-log.1
mv 【移动文件】 【移动的位置】
[root@VM_226_140_centos ~]# mv mysql.gz /home
[root@VM_226_140_centos ~]# cd ..
[root@VM_226_140_centos /]# cd home
[root@VM_226_140_centos home]# ls
lai mysql mysql.gz
mv 【改名文件夹】 【更改后文件夹】
anaconda-ks.cfg install.log install.log.syslog mysql-5.6.26-linux-glibc2.5-x86_64 mysql-5.6.26-linux-glibc2.5-x86_64.tar.gz wget-log wget-log.1
[root@VM_226_140_centos ~]# mv mysql-5.6.26-linux-glibc2.5-x86_64 mysql
[root@VM_226_140_centos ~]# ls
anaconda-ks.cfg install.log install.log.syslog mysql mysql-5.6.26-linux-glibc2.5-x86_64.tar.gz wget-log wget-log.1
rm-删除命令 –f【强制删除】 -r【所有删除】 -i【提示删除】
lai mysql mysql.gz
[root@VM_226_140_centos home]# rm mysql.gz
rm: remove regular file `mysql.gz'? y
[root@VM_226_140_centos home]# ls
lai mysql
mkdir【创建目录】
[root@VM_226_140_centos home]# mkdir oo
[root@VM_226_140_centos home]# ls
lai mysql oo
rmdir【删除空文件夹】
lai mysql oo
[root@VM_226_140_centos home]# rmdir oo
[root@VM_226_140_centos home]# ls
lai mysql
touch 【创建文件】
[root@VM_226_140_centos home]# touch wenj
[root@VM_226_140_centos home]# ls
lai mysql wenj
cat 【浏览文件】head【默认开头十行】 tail【默认结尾十行】more【以页面的形式显示】enter一行,b上一页,空格下一页,q退出。
[root@VM_226_140_centos support-files]# cat mysql.server
#!/bin/sh
~~~~~~~此处省略一万行~~~~~~
exit 0
[root@VM_226_140_centos support-files]#
wc 【显示文件详细信息】
[root@VM_226_140_centos support-files]# wc mysql.server
387 1379 10837 mysql.server
Cat>【创建文件】
内容
Ctel+d退出保存
[root@VM_226_140_centos support-files]# cat > lai.txt
sdddasd[root@VM_226_140_centos support-files]# ls
binary-configure lai.txt magic my-default.cnf mysql-log-rotate mysql.server mysqld_multi.server
[root@VM_226_140_centos support-files]# cat lai.txt
sdddasd[root@VM_226_140_centos support-files]#
find ~ 【文件名】---------查找文件
[root@VM_226_140_centos support-files]# find ~ mysql
/root
/root/.bash_logout
/root/.bash_history
/root/.oracle_jre_usage
/root/.oracle_jre_usage/30ffaef050ac11e.timestamp
find: `mysql': No such file or directory
[root@VM_226_140_centos support-files]#
tr ‘A-Z’ ‘a-z’【重定向,将文件改变大小写】
JJFSaDKaKS
[root@VM_226_140_centos support-files]# tr 'A-Z' 'a-z' <lai.txt
jjfsadkaks
cut 【剪切】-c【显示的字段数】 -fn【n为列数】 -d_【_为分列符号】 文件名
[root@VM_226_140_centos support-files]# cut -d" " -f2 lai.txt【以空格为列】
sds
ss
paste 【文件1】 【文件2】 >合并后文件----------【粘贴】
[root@VM_226_140_centos home]# paste li.txt lai.txt >laij.txt
[root@VM_226_140_centos home]# ls
lai lai.txt laij.txt li.txt mysql
[root@VM_226_140_centos home]# cat laij.txt
kkk ls dsadada
ds oo sdas
sd pp das
tail /etc/shadow-----查看用户密码状态
[root@VM_226_140_centos home]# tail /etc/shadow
nobody:*:15980:0:99999:7:::
vcsa:!!:16429::::::
abrt:!!:16429::::::
ntp:!!:16429::::::
saslauth:!!:16429::::::
postfix:!!:16429::::::
sshd:!!:16429::::::
tcpdump:!!:16429::::::
dbus:!!:16429::::::
mysql:!!:17241:0:99999:7:::
[root@VM_226_140_centos home]#
passwd -uf mysql【用户名】----------清除密码-u不行就-uf强制清除
[root@VM_226_140_centos home]# passwd -uf mysql
Unlocking password for user mysql.
passwd: Success
[root@VM_226_140_centos home]#
vcsa:!!:16429::::::
abrt:!!:16429::::::
ntp:!!:16429::::::
saslauth:!!:16429::::::
postfix:!!:16429::::::
sshd:!!:16429::::::
tcpdump:!!:16429::::::
dbus:!!:16429::::::
mysql::17241:0:99999:7:::
本地需要启动postfix或者sendmail
2、cat mail.txt |mail -s test f@a.com
3、可以以附件方式发送
uuencode a.txt a.txt |mail m@a.com
df –h【查询磁盘大小容量】 du【使用的总量】 df【百分比显示】
[root@VM_226_140_centos home]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/vda1 20G 3.1G 16G 17% /
【权限】
chmod 【u||a||g】(所有者,群组,全部用户)【-||=||+】【r||w||x】(读写执行) 文件名
lai lai.txt laij.txt li.txt mysql
[root@VM_226_140_centos home]# chmod 755 lai.txt
[root@VM_226_140_centos home]# ls
lai lai.txt laij.txt li.txt mysql--------颜色变化
【软链接】
ln -s /usr/local/tomcat /tomcat
ln -s 复杂的目录 简单的目录
total 20
drwx------ 2 501 501 4096 Mar 19 22:04 lai
-rwxr-xr-x 1 root root 18 Mar 20 16:50 lai.txt
-rw-r--r-- 1 root root 38 Mar 20 16:50 laij.txt
-rw-r--r-- 1 root root 18 Mar 20 16:48 li.txt
drwxr-xr-x 13 root root 4096 Mar 19 22:30 mysql
[root@VM_226_140_centos home]# ln /home/lai.txt /lai
[root@VM_226_140_centos home]# ls -l
total 20
drwx------ 2 501 501 4096 Mar 19 22:04 lai
-rwxr-xr-x 2 root root 18 Mar 20 16:50 lai.txt
-rw-r--r-- 1 root root 38 Mar 20 16:50 laij.txt
-rw-r--r-- 1 root root 18 Mar 20 16:48 li.txt
drwxr-xr-x 13 root root 4096 Mar 19 22:30 mysql--------变化,链接通道多了
rm –rf lai.txt 【删除软链接】
[root@VM_226_140_centos home]# rm -rf lai.txt
[root@VM_226_140_centos home]# ls -l
total 16
drwx------ 2 501 501 4096 Mar 19 22:04 lai
-rw-r--r-- 1 root root 38 Mar 20 16:50 laij.txt
-rw-r--r-- 1 root root 18 Mar 20 16:48 li.txt
drwxr-xr-x 13 root root 4096 Mar 19 22:30 mysql
mount【挂载】
mount 【挂载目录】 【挂载空间】(/media/cdrom||media/floppy||/mnt)
eject ./media/cdrom【退出挂载】
ls –l /media/cdrom【查询挂载】
umount 卸载光驱
mount / media/cdrom 重启光驱
【解压文件】tar 【文件名】[-zxvf]
man rpm|more【检查文件是否被修改过】
【安装软件】
rpm –i 【软件名称】---------安装新,保留旧
rpm –u【软件名称】---------安装新,删除旧
rpm –f 【软件名称】--------安装新,升级,无旧不安装
rpm –e 【软件名称】--------卸载软件
rpm –qf【查找一个文件属于哪个rpm包】
rpm –qa【查看所有的软件包】
rpm –qi【显示软件包信息】
rpm –ql【列出包中全部文件】
reboot【重启服务器】
ps –ef【查看进程】
kill –s 9 pid号【杀死该进程】
一、Linux各大文件夹作用
1、root超级权限用户目录
2、home用户的目录,主要用来建立不同的组和不同的用户自家目录,如lai,yue不同的用户不同的文件夹
3、bin命令或者程序的目录
4、sbin可执行文件的目录
5、media挂载目录,内主要有两个目录:media/cdrom光盘挂载目录、media/floppy软盘挂载目录
6、mnt也属于挂载目录
7、dev存放在这台计算机里的所有设备
8、etc主要的配置目录
查看所有挂载的文件:ls -i /media
修改日期和时间:date -s "2012-05-18 04:53:00"
Nohup ./xxx.sh 后台执行
netstat -nat端口查看
数据库导出
mysqldump -uroot lai>lai.sql
[root@VM_226_140_centos ~]# whoami
root
Who---------------查看全部用户
[root@VM_226_140_centos ~]# who
root tty1 Mar 15 09:17
root pts/0 Mar 19 21:19 (27.19.88.163)
Who am i-------------查看当前终端
[root@VM_226_140_centos ~]# who am i
root pts/0 Mar 19 21:19 (27.19.88.163)
W -------------获取大量信息,启动时间,登陆用户,1分钟提交任务。。。。。等
[root@VM_226_140_centos ~]# w
21:23:12 up 17 days, 4:14, 2 users, load average: 0.00, 0.02, 0.00
USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT
root tty1 - Wed09 4days 0.01s 0.01s -bash
root pts/0 27.19.88.163 21:19 0.00s 0.00s 0.00s w
Users ----------目前登陆使用的终端
[root@VM_226_140_centos ~]# users
root root
tty--------------终端控制
[root@VM_226_140_centos ~]# tty
/dev/pts/0
Uname---------操作系统
[root@VM_226_140_centos ~]# uname
Linux
Uname -n------主机名
[root@VM_226_140_centos ~]# uname -n
VM_226_140_centos
Uname -i-------处理器
[root@VM_226_140_centos ~]# uname -i
x86_64
uname -r-------系统版本
[root@VM_226_140_centos ~]# uname -r
2.6.32-504.30.3.el6.x86_64
Uname –s-------操作系统名字
[root@VM_226_140_centos ~]# uname -s
Linux
Uname –p------处理器类型-------怀疑腾讯给的假服务器
[root@VM_226_140_centos ~]# uname -p
x86_64
uname -m--------硬件名称-------怀疑腾讯给的假服务器
[root@VM_226_140_centos ~]# uname -m
x86_64
uname -a-------全部信息
[root@VM_226_140_centos ~]# uname -a
Linux VM_226_140_centos 2.6.32-504.30.3.el6.x86_64 #1 SMP Wed Jul 15 10:13:09 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux
Whatis 【命令】-------帮助
[root@VM_226_140_centos ~]# whatis ls
ls (1) - list directory contents
【命令】--help---------帮助
[root@VM_226_140_centos ~]# su --help
Usage: su [OPTION]... [-] [USER [ARG]...]
Change the effective user id and group id to that of USER.
-, -l, --login make the shell a login shell,
clears all envvars except for TERM,
initializes HOME, SHELL, USER, LOGNAME and PATH
-c, --command=COMMAND pass a single COMMAND to the shell with -c
--session-command=COMMAND pass a single COMMAND to the shell with -c
and do not create a new session
-f, --fast pass -f to the shell (for csh or tcsh)
-m, --preserve-environment do not reset HOME, SHELL, USER, LOGNAME
environment variables
-p same as -m
-s, --shell=SHELL run SHELL if /etc/shells allows it
--help display this help and exit
--version output version information and exit
A mere - implies -l. If USER not given, assume root.
Report su bugs to bug-coreutils@gnu.org
GNU coreutils home page: <http://www.gnu.org/software/coreutils/>
General help using GNU software: <http://www.gnu.org/gethelp/>
Report su translation bugs to <http://translationproject.org/team/>
For complete documentation, run: info coreutils 'su invocation'
date -------时间
[root@VM_226_140_centos ~]# date
Sun Mar 19 21:41:30 CST 2017
Cal --------显示全部
[root@VM_226_140_centos ~]# cal
March 2017
Su Mo Tu We Th Fr Sa
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31
Clear-------清除屏幕
[root@VM_226_140_centos ~]#
Su root ----切换用户
[root@VM_226_140_centos ~]# su lai
[lai@VM_226_140_centos root]$
Passwd--------修改密码
Passwd 【用户名】-------修改该用户密码
[root@VM_226_140_centos ~]# passwd lai
Changing password for user lai.
New password: 【密码】
BAD PASSWORD: it does not contain enough DIFFERENT characters
Retype new password: 【再次输入密码】
passwd: all authentication tokens updated successfully.
Useradd 【用户名】-------------------增加用户
[root@VM_226_140_centos ~]# useradd lai
[root@VM_226_140_centos ~]#
Userdel 【删除的用户】
[root@VM_226_140_centos ~]# cat /etc/passwd
~~~~~~~此处省略一万行~~~~~~
mysql:x:500:500::/home/mysql:/bin/bash
lai:x:501:501::/home/lai:/bin/bash
[root@VM_226_140_centos ~]# userdel lai
[root@VM_226_140_centos ~]# cat /etc/passwd-------查看用户状态
root:x:0:0:root:/root:/bin/bash
~~~~~~~此处省略一万行~~~~~~
mysql:x:500:500::/home/mysql:/bin/bash-------可见lai用户已经被删除
man----手册使用,了解命令功能
[root@VM_226_140_centos man]# man ls
【1表示ls在手册第一章】
LS(1) User Commands LS(1)
NAME
ls - list directory contents
SYNOPSIS
ls [OPTION]... [FILE]...
~~~~~~~此处省略一万行~~~~~~
-c with -lt: sort by, and show, ctime (time of last modification of file status information) with -l: show ctime and sort by name otherwise: sort by ctime
:
退出方法!后Enter
Man具体位置在usr/share/man
pwd---------确定现在位置
[root@VM_226_140_centos home]# pwd
/home
Cd ..------返回上一级 -------本来不准备演示的,和windows相同
[root@VM_226_140_centos home]# cd ..
[root@VM_226_140_centos /]# ls
bin boot data dev etc home lib lib64 lost+found media mnt opt proc root sbin selinux srv sys tmp usr var
ls -l /media--------查看当前挂载项目
[root@VM_226_140_centos /]# ls -l /media
total 0
ls –a -------隐藏文件查看
[root@VM_226_140_centos /]# ls -a
. .. .autofsck .autorelabel bin boot data dev etc home lib lib64 lost+found media mnt opt proc root sbin selinux srv sys tmp usr var
ls -l-------细节文件查看
[root@VM_226_140_centos /]# ls -l
total 104
dr-xr-xr-x. 2 root root 4096 Mar 3 2016 bin
dr-xr-xr-x. 4 root root 4096 Mar 3 2016 boot
~~~~~~~此处省略一万行~~~~~~
drwxr-xr-x. 13 root root 4096 Dec 25 2014 usr
drwxr-xr-x. 19 root root 4096 Mar 3 2016 var
ls -h---------查看文件大小
[root@VM_226_140_centos /]# ls –s
total 104
4 bin 4 boot 4 data 0 dev 4 etc 4 home 4 lib 12 lib64 20 lost+found 4 media 4 mnt 4 opt 0 proc 4 root 12 sbin 4 selinux 4 srv 0 sys 4 tmp 4 usr 4 var
Cp 【源文件】 【新文件】 -----复制(-r复制文件夹解决方式)
cp -r dir1/. dir2 -----如果文件夹存在,则用这种方法,会询问覆盖信息(cp -rf也是这样)
cp -rif a/b/* a1/b1/回车 -----整个文件夹的文件复制,无提示
anaconda-ks.cfg install.log install.log.syslog mysql-5.6.26-linux-glibc2.5-x86_64 mysql-5.6.26-linux-glibc2.5-x86_64.tar.gz wget-log wget-log.1
[root@VM_226_140_centos ~]# cp mysql-5.6.26-linux-glibc2.5-x86_64.tar.gz mysql.gz
[root@VM_226_140_centos ~]# ls
anaconda-ks.cfg install.log install.log.syslog mysql-5.6.26-linux-glibc2.5-x86_64 mysql-5.6.26-linux-glibc2.5-x86_64.tar.gz mysql.gz wget-log wget-log.1
mv 【移动文件】 【移动的位置】
[root@VM_226_140_centos ~]# mv mysql.gz /home
[root@VM_226_140_centos ~]# cd ..
[root@VM_226_140_centos /]# cd home
[root@VM_226_140_centos home]# ls
lai mysql mysql.gz
mv 【改名文件夹】 【更改后文件夹】
anaconda-ks.cfg install.log install.log.syslog mysql-5.6.26-linux-glibc2.5-x86_64 mysql-5.6.26-linux-glibc2.5-x86_64.tar.gz wget-log wget-log.1
[root@VM_226_140_centos ~]# mv mysql-5.6.26-linux-glibc2.5-x86_64 mysql
[root@VM_226_140_centos ~]# ls
anaconda-ks.cfg install.log install.log.syslog mysql mysql-5.6.26-linux-glibc2.5-x86_64.tar.gz wget-log wget-log.1
rm-删除命令 –f【强制删除】 -r【所有删除】 -i【提示删除】
lai mysql mysql.gz
[root@VM_226_140_centos home]# rm mysql.gz
rm: remove regular file `mysql.gz'? y
[root@VM_226_140_centos home]# ls
lai mysql
mkdir【创建目录】
[root@VM_226_140_centos home]# mkdir oo
[root@VM_226_140_centos home]# ls
lai mysql oo
rmdir【删除空文件夹】
lai mysql oo
[root@VM_226_140_centos home]# rmdir oo
[root@VM_226_140_centos home]# ls
lai mysql
touch 【创建文件】
[root@VM_226_140_centos home]# touch wenj
[root@VM_226_140_centos home]# ls
lai mysql wenj
cat 【浏览文件】head【默认开头十行】 tail【默认结尾十行】more【以页面的形式显示】enter一行,b上一页,空格下一页,q退出。
[root@VM_226_140_centos support-files]# cat mysql.server
#!/bin/sh
~~~~~~~此处省略一万行~~~~~~
exit 0
[root@VM_226_140_centos support-files]#
wc 【显示文件详细信息】
[root@VM_226_140_centos support-files]# wc mysql.server
387 1379 10837 mysql.server
Cat>【创建文件】
内容
Ctel+d退出保存
[root@VM_226_140_centos support-files]# cat > lai.txt
sdddasd[root@VM_226_140_centos support-files]# ls
binary-configure lai.txt magic my-default.cnf mysql-log-rotate mysql.server mysqld_multi.server
[root@VM_226_140_centos support-files]# cat lai.txt
sdddasd[root@VM_226_140_centos support-files]#
find ~ 【文件名】---------查找文件
[root@VM_226_140_centos support-files]# find ~ mysql
/root
/root/.bash_logout
/root/.bash_history
/root/.oracle_jre_usage
/root/.oracle_jre_usage/30ffaef050ac11e.timestamp
find: `mysql': No such file or directory
[root@VM_226_140_centos support-files]#
tr ‘A-Z’ ‘a-z’【重定向,将文件改变大小写】
JJFSaDKaKS
[root@VM_226_140_centos support-files]# tr 'A-Z' 'a-z' <lai.txt
jjfsadkaks
cut 【剪切】-c【显示的字段数】 -fn【n为列数】 -d_【_为分列符号】 文件名
[root@VM_226_140_centos support-files]# cut -d" " -f2 lai.txt【以空格为列】
sds
ss
paste 【文件1】 【文件2】 >合并后文件----------【粘贴】
[root@VM_226_140_centos home]# paste li.txt lai.txt >laij.txt
[root@VM_226_140_centos home]# ls
lai lai.txt laij.txt li.txt mysql
[root@VM_226_140_centos home]# cat laij.txt
kkk ls dsadada
ds oo sdas
sd pp das
tail /etc/shadow-----查看用户密码状态
[root@VM_226_140_centos home]# tail /etc/shadow
nobody:*:15980:0:99999:7:::
vcsa:!!:16429::::::
abrt:!!:16429::::::
ntp:!!:16429::::::
saslauth:!!:16429::::::
postfix:!!:16429::::::
sshd:!!:16429::::::
tcpdump:!!:16429::::::
dbus:!!:16429::::::
mysql:!!:17241:0:99999:7:::
[root@VM_226_140_centos home]#
passwd -uf mysql【用户名】----------清除密码-u不行就-uf强制清除
[root@VM_226_140_centos home]# passwd -uf mysql
Unlocking password for user mysql.
passwd: Success
[root@VM_226_140_centos home]#
vcsa:!!:16429::::::
abrt:!!:16429::::::
ntp:!!:16429::::::
saslauth:!!:16429::::::
postfix:!!:16429::::::
sshd:!!:16429::::::
tcpdump:!!:16429::::::
dbus:!!:16429::::::
mysql::17241:0:99999:7:::
本地需要启动postfix或者sendmail
2、cat mail.txt |mail -s test f@a.com
3、可以以附件方式发送
uuencode a.txt a.txt |mail m@a.com
df –h【查询磁盘大小容量】 du【使用的总量】 df【百分比显示】
[root@VM_226_140_centos home]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/vda1 20G 3.1G 16G 17% /
【权限】
chmod 【u||a||g】(所有者,群组,全部用户)【-||=||+】【r||w||x】(读写执行) 文件名
lai lai.txt laij.txt li.txt mysql
[root@VM_226_140_centos home]# chmod 755 lai.txt
[root@VM_226_140_centos home]# ls
lai lai.txt laij.txt li.txt mysql--------颜色变化
【软链接】
ln -s /usr/local/tomcat /tomcat
ln -s 复杂的目录 简单的目录
total 20
drwx------ 2 501 501 4096 Mar 19 22:04 lai
-rwxr-xr-x 1 root root 18 Mar 20 16:50 lai.txt
-rw-r--r-- 1 root root 38 Mar 20 16:50 laij.txt
-rw-r--r-- 1 root root 18 Mar 20 16:48 li.txt
drwxr-xr-x 13 root root 4096 Mar 19 22:30 mysql
[root@VM_226_140_centos home]# ln /home/lai.txt /lai
[root@VM_226_140_centos home]# ls -l
total 20
drwx------ 2 501 501 4096 Mar 19 22:04 lai
-rwxr-xr-x 2 root root 18 Mar 20 16:50 lai.txt
-rw-r--r-- 1 root root 38 Mar 20 16:50 laij.txt
-rw-r--r-- 1 root root 18 Mar 20 16:48 li.txt
drwxr-xr-x 13 root root 4096 Mar 19 22:30 mysql--------变化,链接通道多了
rm –rf lai.txt 【删除软链接】
[root@VM_226_140_centos home]# rm -rf lai.txt
[root@VM_226_140_centos home]# ls -l
total 16
drwx------ 2 501 501 4096 Mar 19 22:04 lai
-rw-r--r-- 1 root root 38 Mar 20 16:50 laij.txt
-rw-r--r-- 1 root root 18 Mar 20 16:48 li.txt
drwxr-xr-x 13 root root 4096 Mar 19 22:30 mysql
mount【挂载】
mount 【挂载目录】 【挂载空间】(/media/cdrom||media/floppy||/mnt)
eject ./media/cdrom【退出挂载】
ls –l /media/cdrom【查询挂载】
umount 卸载光驱
mount / media/cdrom 重启光驱
【解压文件】tar 【文件名】[-zxvf]
man rpm|more【检查文件是否被修改过】
【安装软件】
rpm –i 【软件名称】---------安装新,保留旧
rpm –u【软件名称】---------安装新,删除旧
rpm –f 【软件名称】--------安装新,升级,无旧不安装
rpm –e 【软件名称】--------卸载软件
rpm –qf【查找一个文件属于哪个rpm包】
rpm –qa【查看所有的软件包】
rpm –qi【显示软件包信息】
rpm –ql【列出包中全部文件】
reboot【重启服务器】
ps –ef【查看进程】
kill –s 9 pid号【杀死该进程】
一、Linux各大文件夹作用
1、root超级权限用户目录
2、home用户的目录,主要用来建立不同的组和不同的用户自家目录,如lai,yue不同的用户不同的文件夹
3、bin命令或者程序的目录
4、sbin可执行文件的目录
5、media挂载目录,内主要有两个目录:media/cdrom光盘挂载目录、media/floppy软盘挂载目录
6、mnt也属于挂载目录
7、dev存放在这台计算机里的所有设备
8、etc主要的配置目录
查看所有挂载的文件:ls -i /media
修改日期和时间:date -s "2012-05-18 04:53:00"
Nohup ./xxx.sh 后台执行
netstat -nat端口查看
数据库导出
mysqldump -uroot lai>lai.sql