# Linux常用設定 ###### tags: `常用設定`, `Linux` ## fstab ``` blkid -s UUID # /etc/fstab /dev/disk/by-uuid/[UUID] / ext4 defaults 0 1 ``` ## hostname ``` console hoastname [hostname] ``` ``` # /etc/hostname [hostname] # /etc/hosts 127.0.0.1 [hostname] ``` ## wifi ``` # /etc/wpa_supplicant/wpa_supplicant.conf country=TW ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev update_config=1 network={ ssid="name" psk="passwd" key_mgmt=WPA-PSK } ``` ## network ``` # /etc/network/interfaces auto lo iface lo inet loopback allow-hotplug eth0 iface wlan0 inet static address 192.168.0.202 network 255.255.255.0 allow-hotplug wlan0 iface wlan0 inet dhcp wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf ``` ## ssh ``` #/etc/ssh/sshd_config #PermitRootLogin yes ``` ## auto_start ``` # /etc/rc.local # wifi wpa_supplicant -B -i wlan0 -c /etc/wpa_supplicant/wpa_supplicant.conf dhclient # ssh /etc/init.d/ssh start ``` ## crontab ``` #/etc/crontab SHELL=/bin/sh PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin # matsu 0,30 5-19/1 * * * root /root/matsu/airport_info_zero 2 */1 * * * root /root/matsu/ship_info_zero 6 */1 * * * root /root/matsu/matsu_info_zero 8 7-20/1 * * * root /root/matsu/aqi_alert_zero # comic 0 */6 * * * root /root/rouman5/updateComic_zero ``` ### crontab -e ```console @reboot sleep 60; /bin/bash /root/line_ip.sh ``` ## 常用shell ``` console # dk.sh ps aux | grep "$1" ps aux | grep "$1" | awk '{print $2}' | sudo xargs kill -9 ``` ``` console # dldeb.sh PACKAGE=$1 URI=`apt-cache show $PACKAGE | grep "Filename:" | cut -f 2 -d " "` wget http://raspbian.raspberrypi.org/raspbian/$URI ``` ``` console # nat.sh iptables --table nat --append POSTROUTING --out-interface enp0s3 -j MASQUERADE iptables --append FORWARD --in-interface enp0s8 -j ACCEPT echo "1" > /proc/sys/net/ipv4/ip_forward ``` ``` console # cron.sh nano /etc/crontab && /etc/init.d/cron restart ``` ``` console # cpu_temp.sh vcgencmd measure_temp ``` ```console # cpu_usage.sh top -b -n2 | grep "Cpu(s)"|tail -n 1 | awk '{print $2 + $4}' ps -eo pid,ppid,cmd,%mem,%cpu --sort=-%cpu | head top -b -o +%CPU | head -n 17 ``` ``` console # ngrok.sh ngrok http 5000 --log=stdout > /tmp/ngrok.log & ``` ## .bashrc ``` # ~/.bashrc # W 改大寫 if [ "$color_prompt" = yes ]; then PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\W \$\[\033[00m\] ' else PS1='${debian_chroot:+($debian_chroot)}\u@\h:\W\$ ' fi # 關閉app alias dk='dk' function dk() { /root/dk.sh $1;} ``` ## 基本服務 ### samba ``` console adduser [userName] smbpasswd -a [userName] ``` ``` # /etc/samba/smb.conf [tmp] comment = tmp path = /tmp browseable = yes read only = no create mask = 0644 directory mask = 0755 valid users = userName ``` ### 時間對時 [ntp 設定]( https://hackmd.io/rKYutyveQLyyS8Tc5cuGSQ) ## 關閉傳送內部錯誤 ``` #/etc/default/apport enbable=0 ``` ## sudo no passwd ``` visudo # /etc/sudoers # Allow members of group sudo to execute any command %sudo ALL=(ALL:ALL) ALL xxxx ALL=(ALL:ALL) NOPASSWD: ALL ``` ## informatrion ``` console # linux版本 lsb_release -a # cpu cat /proc/cpuinfo # mem cat /proc/meminfo # 記憶體使用狀況 free -m # 硬體資訊 dmidecode # 顯示卡型號 lspci | grep VGA # 硬碟資訊 smartctl -a /dev/sda # USB lsusb # kernel版本 uname -a # kernel logs dmesg ``` ## TimeZone `cp /usr/share/zoneinfo/Asia/Taipei /etc/localtime`
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up