Thứ Sáu, 3 tháng 6, 2011

Manage and working on files

_ Create a folder

# mkdir /data
# mkdir -p /data

_ List a folder

# ls /boot
# ls -l /etc

_ Create a file

# echo "hello" > /data/hello.txt
# echo "chao" >> /data/hello.txt
# cat > /data/bye.txt
nhap noi dung
Ctrl+D to save

# cat >> /data/bye.txt
nhap noi dung
Ctrl+D to save

_ Create an empty file

# touch /data/empty

_ View file commands: cat, more, less, head, tail

# cat /data/hello.txt

_ Copying file

# cp /data/hello.txt /backup
# cp /data/bye.txt /backup/tambiet.txt
# cp -rf /data /backup/linux
# cp -rf /data /backup/linux/dulieu

_ Moving file

# mv /backup/hello.txt /backup/linux
# mv /backup/tambiet.txt /backup/linux/bb.txt

_ Deleting file, folder

# rm /data/bye.txt
# rm -rf /backup/linux
# rmdir /emptyfolder

_ Current working directory

# pwd

_ Finding a file, folder

# find / -name http.conf
find command: take a deep look on it!

_ Search a string in file

# grep "default" /etc/inittab

_ Find command's position

# which grep
# whereis find

_ Nen file
#gzip /data/hello.txt
#bzip2 /backup/linux/hello.txt

_ Bung nen:
#gzip -d /data/hello.txt.gz
#bzip2 -d /backup/linux/hello.txt.bz2

_ Gom nhieu file, thu muc thanh 1 file: tar
#cp /etc/passwd /etc/group /data
#cd /data
#tar -cvf backup.tar passwd group

_ Untar:
#tar -xvf backup.tar

_ Xem inode number cua file, thu muc:
#ls -i /data/passwd
#ls -id /data

_ Tao symbolic link (softlink):
#cd /data
#ln -s passwd soft
#ls -l /data

_ Tao hardlink:
#cd /data
#ln group hard
#ls -i
#rm group
#more hard

_ Tien ich soan thao file:
+ Tien ich nano: #nano /data/file1
+ Tien ich vi: #vi /data/file2
:w save
:x save + quit
:q quit
:q! quit without save
:set nu hien so hang

0 nhận xét:

Đăng nhận xét

Twitter Delicious Facebook Digg Stumbleupon Favorites More

 
Design by netdohoa | Support for this Theme dohoavietnam