Linux經常使用命令

1、文件操做
# 建立目錄
mkdir fortest
# 加 -p 能夠建立多級目錄,且不要求其父目錄存在
mkdir -p fortest/test/d
 
# 建立一個空文件
touch file.txt
 
# 向文件中寫入一句話(若是文件不存在會建立)
echo 「hello,word」 > test.txt
# 使用兩個大於號能夠進行追加,不會先清空文件
echo 「hello,word」 >> test.txt
 
# 查看文件,後二者可分頁查看
cat 、less、more
 
# 分別打印文件的前10行與後10行
head、tail
 
# gzip壓縮,經常使用後綴爲.gz
gzip test.txt  # 壓縮
gzip -d test.txt.gz # 解壓
 
# tar打包壓縮,經常使用後綴爲.tar.bz2 和 .tar.gz
tar jcvf test.tar.bz2 test.txt  # 壓縮
tar jxvf test.tar.bz2  # 解壓bz2文件
 
# 打包並調用gzip壓縮gz格式的文件
tar zcvf test.tar.gz test.txt # 壓縮
tar axvf test.tar.gz  # 解壓
 
2、權限管理
# chown 修改文件所屬的用戶和所屬的組
chown user /home/joy/test.txt
# 修改文件所屬用戶 user , 同時屬於組 group2
chown user:group2 /home/joy/test.txt
 
# chmod 用於修改文件的權限,分別對用戶屬主(u),組(g),其餘(o)進行配置
chmod u+x /home/joy/test.txt
chmod g+w /home/joy/test.txt
chmod o-r /home/joy/test.txt
 
# chmod 還能夠用3位0-7的數字來對三組權限進行同時設置,每位數字分別表明讀(4)、寫(2)和執行(1)
chmod 740 /home/joy/test.txt # 740表明 rwxr——
chmod 764 /home/joy/test.txt # 764表明 rwxrw-r—
 
# -參數,表示也同時切換 hdfs 的環境變量
sudo su - hdfs
# 在 HDFS 文件系統中創建一個目錄,並將目錄的屬主修改成普通用戶,方便後續操做
hdfs dfs -mkdir /data
hdfs dfs -chown joy:dataml /data
 
3、軟件安裝
# Ubuntu 和 Debain 採用的方式
apt-get install emacs24
 
# CentOs 和 Fedora 採用的方式
yum install emacs24
 
# Mac 採用的方式
 brew install emacs24
 
# 對於要編譯的軟件
# 配置環境,檢查依賴
./configure —prefix=/usr/local/nginx
# 編譯
make
# 安裝,一般須要root權限
sudo make install 
 
# 對於解壓便可用的程序
# 下載軟件
# 解壓
tar xvf jdk8.tar.gz
# 移動到 /opt 目錄,方便管理
mv jdk8 /opt/
# 添加路徑到 PATH 環境變量
echo 「export PATH=/opt/jdk/bin:$PATH」 >> ~/.bashrc
# 應用環境變量
source ~/.bashrc
# 測試命令
which java
相關文章
相關標籤/搜索