20 lenh linux
- 1. L動u 箪:
Th動 m畛c, 動畛ng d畉n 畉n th動 m畛c th動畛ng k畉t th炭c b畛i k箪 t畛 /
File, 動畛ng d畉n 畉n file kh担ng c坦 k箪 t畛 / 畛 cu畛i
M畛t file tr棚n Linux kh担ng ph畉i l炭c no c滴ng c坦 u担i 畉ng sau
20 c但u l畛nh SSH th担ng d畛ng nh畉t
1. Di chuy畛n gi畛a c叩c th動 m畛c
cd [another directory]
VD: chuy畛n 畉n th動 m畛c ch畛a file c畉u h狸nh Nginx
cd /etc/nginx/conf.d/
2. Chuy畛n 畉n th動 m畛c home c畛a user
cd ~
N畉u b畉n login b畉ng ti kho畉n root th狸 l炭c ny th動 m畛c home s畉 l /root
3. Chuy畛n 畉n th動 m畛c tr動畛c 但y
cd -
4. Di chuy畛n 畉n th動 m畛c cha
cd ..
5. Hi畛n th畛 動畛ng d畉n th動 m畛c hi畛n t畉i
pwd
6. Hi畛n th畛 t畉t c畉 file/th動 m畛c 畛 th動 m畛c hi畛n t畉i
ls
7. Hi畛n th畛 t畉t c畉 file v th担ng tin
ls -al
- 2. 8. Hi畛n th畛 t畉t c畉 file v畛i u担i b畉t k畛
ls *.ext
VD: hi畛n th畛 ton b畛 file *.PHP
ls *.php
9. Hi畛n th畛 t畉t c畉 file/th動 m畛c v畛i th担ng tin chi ti畉t
ls -alh
10. T畉t k畉t n畛i SSH
exit
Qu畉n l箪 File
11. Copy v 畛i t棚n file
File c滴 v畉n 動畛c gi畛 nguy棚n.
cp [filename] [new filename]
VD: copy v 畛i t棚n file banner.jpg thnh banner728px.jpg
cp banner.jpg banner728px.jpg
VD: copy banner.jpg vo folder ads v 畛i t棚n thnh banner728px.jpg
cp banner.jpg ads/banner728px.jpg
12. Move v 畛i t棚n file
File c滴 s畉 b畛 x坦a v chuy畛n sang th動 m畛c m畛i.
mv [old filename] [new filename]
VD: di chuy畛n banner.jpg sang folder ads
- 3. mv banner.jpg ads/banner.jpg
VD: di chuy畛n banner.jpg sang folder ads v 畛i t棚n file thnh banner728px.jpg
mv banner.jpg ads/banner728px.jpg
T動董ng t畛, b畉n c坦 th畛 di chuy畛n c畉 folder.
VD: chuy畛n folder image vo folder media
mv image/ media
VD: chuy畛n folder image ra th動 m畛c cha
mv image/ ..
13. X坦a m畛t file
rm [file name]
VD: x坦a file banner.jpg
rm banner.jpg
14. X坦a ton b畛 file 畛 th動 m畛c hi畛n t畉i
rm *
15. X坦a ton b畛 file v畛i extension b畉t k畛
rm *.ext
VD: x坦a ton b畛 file .jpg
rm *.jpg
16. Copy m畛t folder k竪m theo ton b畛 files, th動 m畛c b棚n trong
cp -r [directory] [new directory]
17. T畉o th動 m畛c m畛i
- 4. mkdir [folder name]
VD:
mkdir image
18. T狸m ki畉m m畛t file t畛 th動 m畛c hi畛n t畉i
find . -name [filename] -print
VD: t狸m file banner.jpg 畛 th動 m畛c hi畛n t畉i
find . -name banner.jpg -print
19. T狸m ki畉m n畛i dung trong m畛t file
grep [text] [filename]
VD: t狸m t畛 sidebar trong file index.php
grep sidebar index.php
20. CHMOD thay 畛i file permission
chmod [permission type] [file/folder name]
VD:
chmod 777 wp-config.php
C叩ch 畉t permission:
S畛 畉u ti棚n cho file owner, s畛 th畛 2 cho group c畛a owner, v s畛 th畛 3 cho ton b畛 user v g
roup kh叩c.
7 = Read + Write + Execute
6 = Read + Write
5 = Read + Execute
4 = Read
- 5. 3 = Write + Execute
2 = Write
1 = Execute
0 = All access denied