Giter Site home page Giter Site logo

linux's Introduction

Useful Linux commands

Collection of commands/scripts for Linux. Listed below are commands I frequently use but often forget the exact syntax for:

Link to Docker

https://github.com/chrnnk/docker

Misc commands - uptime, load average, io load, etc

uptime
ps auxf
ping -c 10
less -R
date='date "+%Y-%m-%d %A %T %Z"'

CPU Usage

cat /prox/loadavg
htop
ps aux | grep
ps -eo pcpu,pid,user,args | sort -k 1 -r | head -10"

Show subfolder disk usage for current folder

du * -sh | sort -hr
du -shc docker/appdata/* | sort -hr | head -25

Check power on hours for all drives

for drive in $(ls -la /dev | grep -Ev 'sda|sd[a-z][0-9]' | grep sd[a-z] | awk '{print $10}'); do hours=$(smartctl --all /dev/${drive} | grep Power_On_Hours | awk '{print $10}'); echo "Power on Hours for ${drive}: ${hours}"; echo ''; done

Find file and grep

Search files in the current folder

find . | grep

Colorize grep results

cat file.ext | grep --color TextToSearch

Copy files examples

rsync -avP /mnt/serenity/folder/ /mnt/nas-media/folder/ --bwlimit=20000
cp -avr /folder/*.iso /folder/iso/
rsync -avP /folder/iso/ /folder/iso/ --stats --progress

Copy file from website

sudo curl -L https://raw.githubusercontent.com/chrnnk/docker/main/ubuntu-setup/create-folders.sh -o ~/scripts/create-folders.sh

Grub commands

/etc/default/grub
sudo cp /etc/default/grub /etc/default/grub.bak
sudo nano /etc/default/grub
sudo update-grub

Add ssh keys

sudo nano ~/.ssh/authorized_keys

Neofetch config

nano ~/.config/neofetch/config.conf

Tar.gz and untar

tar -czvf archive.tar.gz /usr/folder/name
tar -xf archive.tar.gz -C /usr/folder/name
mktar = 'tar -cvf'
mkbz2 = 'tar -cvjf'
mkgz = 'tar -cvzf'
untar = 'tar -xvf'
unbz2 = 'tar -xvjf'
ungz = 'tar -xvzf'

Services

sudo systemctl status plexmediaserver

Bash

Run script from website

wget -O - https://raw.githubusercontent.com/chrnnk/docker/main/ubuntu-setup/create-folders.sh | bash

Type clipboard as keystrokes

sleep 3; xdotool type "$(xclip -o -selection clipboard)"

Updates

Update all with sudo apt

sudo apt update && sudo apt upgrade -y && sudo apt dist-upgrade -y && sudo apt autoremove -y

Update all with sudo nala

sudo nala update && sudo nala upgrade -y && sudo nala clean && sudo nala autoremove && sudo nala autopurge

Update all without sudo nala

nala update && nala upgrade -y && nala clean && nala autoremove && nala autopurge

In most cases this will give the kept-back packages what they need to successfully upgrade:

sudo apt install <list of packages kept back>

Force install kept-back packages

sudo apt --with-new-pkgs upgrade

Logging

tail -f /var/log/syslog
sudo find /var/log -type f -exec file {} \; | grep 'text' | cut -d' ' -f1 | sed -e's/:$//g' | grep -v '[0-9]$' | xargs tail -f

Networking

Restart all network adapters

ifdown -a && ifup -a

Show current network connections to the server

netstat -anpl | grep :80 | awk {'print \$5'} | cut -d\":\" -f1 | sort | uniq -c | sort -n | sed -e 's/^ *//' -e 's/ *\$//'

Show open ports

netstat -nape --inet

Ubuntu server networking

cd /etc/netplan
ls
sudo nano FILENAME.yaml
# fix networking
network:
  ethernets:
    ens18:
      dhcp4: false
      addresses:
        -  IPADDRESS/24
      gateway4: GATEWAY
      nameservers:
        addresses: [1.1.1.1,8.8.8.8]
  version: 2
# save file
sudo netplan try
sudo netplan apply

linux's People

Contributors

chrnnk avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.