Linux基礎筆記
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 [email protected]
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 [email protected]
3、可以以附件方式發送
uuencode a.txt a.txt |mail [email protected]
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 [email protected]
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 [email protected]
3、可以以附件方式發送
uuencode a.txt a.txt |mail [email protected]
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
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.