Linux 基本命令操作
Linux 基本命令操作
文件和目录操作
列出目录内容
1
ls
输出示例:
1
file1.txt file2.txt directory1 directory2
切换到指定目录
1
cd directory1
输出示例:
1
(无输出,仅切换目录)
显示当前工作目录
1
pwd
输出示例:
1
/home/user/directory1
创建新目录
1
mkdir new_directory
输出示例:
1
(无输出,仅创建目录)
删除文件
1
rm file1.txt
输出示例:
1
(无输出,仅删除文件)
文件内容查看和编辑
显示文件内容
1
cat file2.txt
输出示例:
1
This is the content of file2.txt.
分页显示文件内容
1
more file2.txt
输出示例:
1
2This is the content of file2.txt.
--More-- (按空格键翻页)编辑文件
1
nano file2.txt
输出示例:
1
(进入 nano 编辑界面)
文件权限和所有权
更改文件权限
1
chmod 755 file2.txt
输出示例:
1
(无输出,仅更改权限)
更改文件所有者
1
sudo chown newuser file2.txt
输出示例:
1
(无输出,仅更改所有者)
系统管理
显示当前运行的进程
1
ps
输出示例:
1
2
3PID TTY TIME CMD
1056 pts/0 00:00:00 bash
1082 pts/0 00:00:00 ps实时显示系统资源使用情况
1
top
输出示例:
1
2
3
4
5top - 10:45:14 up 2 days, 4:22, 1 user, load average: 0.00, 0.01, 0.05
Tasks: 118 total, 1 running, 117 sleeping, 0 stopped, 0 zombie
%Cpu(s): 0.7 us, 0.3 sy, 0.0 ni, 99.0 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st
KiB Mem : 2048576 total, 192652 free, 1298964 used, 556960 buff/cache
KiB Swap: 1048572 total, 1048572 free, 0 used. 652632 avail Mem清除journalctl系统日志
1
journalctl --flush --rotate --vacuum-time=1s
显示磁盘使用情况
1
df -h
输出示例:
1
2
3Filesystem Size Used Avail Use% Mounted on
/dev/sda1 20G 9.3G 9.1G 51% /
tmpfs 996M 1.2M 995M 1% /run关机或重启系统
1
sudo shutdown -h now
输出示例:
1
(系统会显示关机通知并在几秒钟后关机)
网络相关
检测网络连接
1
ping google.com
输出示例:
1
2PING google.com (172.217.164.110) 56(84) bytes of data.
64 bytes from lga25s61-in-f14.1e100.net (172.217.164.110): icmp_seq=1 ttl=54 time=10.8 ms设置 terminal proxy
1
2export http_proxy="http://192.168.50.1:58080"
export https_proxy="http://192.168.50.1:58080"使用 proxychains proxy
A. 安装 proxychains
1
apt install proxychains
B. 修改配置文件
1
2
3
4
5
6
7
8
9
10nano /etc/proxychains.conf
# Quiet mode (no output from library)
quiet_mode
[ProxyList]
# add proxy here ...
# meanwile
# defaults set to "tor"
#socks4 127.0.0.1 9050
http 192.168.50.1 58080C. 使用
1
proxychains apt update
软件安装相关
apt 安装软件
1
2apt update
apt install stressapt 卸载软件
1
apt remove stress
apt 搜索软件
1
apt search stress
dpkg 查看已安装软件信息
1
dpkg -l
编译安装
A. 安装编译组件
1
apt install -y build-essential
B. 下载并解压 source code
1
2wget https://jaist.dl.sourceforge.net/project/smartmontools/smartmontools/7.4/smartmontools-7.4.tar.gz
tar xvf smartmontools-7.4.tar.gzC. 编译
1
2
3cd smartmontools-7.4/
./configure
make && make installD. 检查是否成功编译安装
1
smartctl -v
本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 FrankTest!
评论
