Linux Basic Commands

 

Các lệnh tương tự Windows: echo , mkdir, cd ,

 

$ mkdir soft

$ cd soft

$ echo $HOME

 

Lệnh xem nội dung file: cat (gần giống lệnh type trên Windows)

 

$ cat /etc/passwd

$ cat /etc/hosts

$ cat /etc/resolv.conf

$ cat /etc/*lsb*

 

Lệnh liệt kê thư mục: ls (gần giống lệnh dir trên Windows)

 

$ ls

$ ls -a

$ ls -l -a

 

Lệnh đổi quyền thư mục (hoặc file): chmod

 

$ chmod 777 -R $HOME

$ chmod +x $HOME/*

 

Lệnh thực thi như super user “do” (quyền admin): sudo

 

$ sudo mkdir /opt/soft

$ sudo chmod 777 -R /opt/soft

 

Lệnh lọc bớt các dòng theo nội dung: grep

 

$ cat /etc/passwd | grep home

$ ls -la | grep rc

$ ps -ef | grep java

 

Lệnh xem process đang chạy: ps

 

$ ps

$ ps aux

$ ps -ef

 

Lệnh tắt (kill) process đang chạy (có process ID 1234) : kill

 

$ sudo kill -9 1234

 

Lệnh tắt (kill) process đang chạy chiếm port (VD: 8080 TCP): fuser

 

$ sudo fuser -k 8080/tcp

 

Lệnh xóa thư mục: rm

 

$ rm /tmp/somefile

$ rm -rf /tmp/someDir

 

Lệnh đổi tên thư mục, di chuyển file: mv

 

Lệnh cài đặt dùng APT trên họ Linux Debian (Ubuntu/Mint/… ): apt-get install

 

$ sudo apt-get install samba

$ sudo apt-get update

$ sudo apt-get install postgresql

 

(phiên bản mới chỉ cần “apt” thay vì “apt-get” , cũng là tải về wget rồi cài bằng dpkg -i )

 

Lệnh cài đặt dùng APT trên họ Linux RedHat (CentOS/FedoraCore/RHEL/… ): yum install

 

$ su -u root && yum install samba

$ yum -y install firefox

 

Truy xuất file sharing trên mạng chia sẻ bằng giao thức Samba (SMB/CIFS):

smb://10.161.207.75/

(tương ứng với trên Windoze: \\10.161.207.75 )

 

Lệnh thêm user trên họ Debian (Ubuntu/Mint/… ): useradd / adduser, thêm nhóm: usermod

 

$ sudo adduser ducquoc

$ sudo usermod -aG sudo ducquoc

(vừa thêm user “ducquoc” đồng thời thêm vào nhóm “sudo” )

$ sudo adduser ducquoc sudo

 

Lệnh đổi mật khẩu: passwd (thường dùng kèm sudo hoặc trước đó cần su )

$ sudo passwd

$ sudo passwd ducquoc 

 

 

 

Vietnamese references

https://ducquoc.wordpress.com/2010/12/04/linux-directory-structure/

https://files.fosswire.com/2012/05/fwunixref_vi.pdf

https://quantrimang.com/mot-so-lenh-linux-co-ban-60400

 

More references

https://linoxide.com/linux-command/essential-linux-basic-commands/

http://www.comptechdoc.org/os/linux/usersguide/linux_ugbasics.html

https://askubuntu.com/

https://superuser.com/

 

./.

 

About DucQuoc.wordpress.com

A brother, husband and father...
This entry was posted in Coding, Linux. Bookmark the permalink.

1 Response to Linux Basic Commands

  1. Pingback: DualBoot Ubuntu Win 10 | DucQuoc's Blog

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s