Linux Commands

September 25, 2018
command purpose notes
lsblk Lists out all the storage blocks, which includes disk partitions and optical drives. Details include the total size of the partition/block and the mount point if any. https://unix.stackexchange.com/questions/4561/how-do-i-find-out-what-hard-disks-are-in-the-system
diskutil list mac tool to list disks
df -h Df is not a partitioning utility, but prints out details about only mounted file systems. The list generated by df even includes file systems that are not real disk partitions. http://www.binarytides.com/linux-command-check-disk-partitions/
du -h /dev/root The du(i.e.,disk usage)command reports the sizes of directory treesinclusive of all of their contents and the sizes of individualfiles. This makes it useful for tracking downspace hogs, i.e.,directoriesand files that consume large or excessive amounts of space on ahard disk drive(HDD) or otherstoragemedia. http://www.linfo.org/du.html
du -k ~/Dropbox/* | awk '$1 > 500000' find folders over 500mb
useradd -m add a user with home folder
passwd manage passwords
ls -la list files
ls -lt list files most recently modified DESC
less /etc/passwd list users https://www.digitalocean.com/community/tutorials/how-to-view-system-users-in-linux-on-ubuntu
less /etc/group list groups https://www.digitalocean.com/community/tutorials/how-to-view-system-users-in-linux-on-ubuntu
w who https://www.digitalocean.com/community/tutorials/how-to-view-system-users-in-linux-on-ubuntu
uname -a display kernel version
cat /proc/version see kernel and gcc version
fdisk -l | grep Disk The fdisk command is partition table manipulator for Linux. But it can be used to display total hard disk size https://www.cyberciti.biz/faq/howto-find-out-or-learn-harddisk-size-in-linux-or-unix/
fdisk /dev/mmcblk0 open fdisk to change partition https://www.safaribooksonline.com/library/view/penetration-testing-with/9781787126138/ch01s06.html
parted /dev/mmcblk0 partition manager for mmcblk0 partition https://www.safaribooksonline.com/library/view/penetration-testing-with/9781787126138/ch01s06.html
resize2fs /dev/mmcblk0p2 resize partition https://www.safaribooksonline.com/library/view/penetration-testing-with/9781787126138/ch01s06.html
tar -xzf file.tar.gz extract tar
ip route show 0.0.0.0/0 dev eth0 | cut -d -f3 find gateway ip https://serverfault.com/questions/31170/how-to-find-the-gateway-ip-address-in-linux
$(ip route | grep default | cut -d ' ' -f 3) find gateway ip for default
hostname -i find ip address for host
vmstat vm stats such as disk, memory, etc
free -m show free memory
uptime machine up time, users, avg load
who who is logged on alias: w
ps aux | grep ngrok find app and filter by name 'ngrok'
ssh-keygen -R {hostname} remove {hostname} from known hosts https://www.cyberciti.biz/faq/mac-os-x-remove-known-host/
jps -lvm get startup params of jvm

File permissions

http://www.tldp.org/LDP/intro-linux/html/sect_03_04.html