Posts

Showing posts from 2017

tar -xvzf archive.tar.gz -C folder

tar -xvzf archive.tar.gz -C folder

wget -O file URL

wget -O file URL

sublime text - text editor tool | Pretty JSON: Format (Pretty Print) JSON

sublime text - text editor tool ctrl+shift+p -> install package-> JSON Pretty ctrl+shift+p-> Pretty JSON: Format (Pretty Print) JSON

mount --bind

A  bind mount  is an alternate view of a directory tree. Classically, mounting creates a view of a storage device as a directory tree. A bind mount instead takes an existing directory tree and replicates it under a different point. The directories and files in the bind mount are the same as the original. Any modification on one side is immediately reflected on the other side, since the two views show the same data. mount --bind <olddir> <mountpoint>

apt-get install --no-install-recommends

That's correct. By default, Ubuntu installs recommended but not suggested packages. With --no-install-recommends, only the main dependencies (packages in the Depends field) are installed.

Writing basic systemd service files

Step 1 : I created this file (note location) which essentially fires a bash process with an extended argument. You could fire your own command which could be different from bash. [root@y500-fedora ~]# cat /etc/systemd/system/foo.service [Unit] Description=foo [Service] ExecStart=/bin/bash -c "while true; do /bin/inotifywait -qq --event close_write /sys/class/backlight/acpi_video0/brightness; su myusername -c '/bin/xbacklight -display :0 -set $(cat /sys/class/backlight/acpi_video0/brightness)'; done" [Install] WantedBy=multi-user.target Step 2 : Reload  systemd : systemctl daemon-reload Start the new service: systemctl enable foo (similarly you can  disable  it) (optional) Step 3 : It should start automatically at next reboot into multi-user mode (run level 3) but if you want to start it right away: systemctl start foo systemctl status foo # optional, just to verify

ubuntu check package version | apt-cache policy init-system-helpers

ubu1404@ubuntu:~$ apt-cache policy init-system-helpers init-system-helpers:   Installed: 1.14ubuntu1   Candidate: 1.14ubuntu1   Version table:  *** 1.14ubuntu1 0         500 http://us.archive.ubuntu.com/ubuntu/ trusty-updates/main amd64 Packages         100 /var/lib/dpkg/status      1.14 0         500 http://us.archive.ubuntu.com/ubuntu/ trusty/main amd64 Packages ubu1404@ubuntu:~$

nmcli device show ens33

swarm-lb0@ubuntu:~$ nmcli device show ens33 GENERAL.DEVICE:                         ens33 GENERAL.TYPE:                           ethernet GENERAL.HWADDR:                         00:0C:29:6F:2E:01 GENERAL.MTU:                            1500 GENERAL.STATE:                          100 (connected) GENERAL.CONNECTION:                     Wired connection 1 GENERAL.CON-PATH:                       /org/freedesktop/NetworkManager/ActiveConnection/1 WIRED-PROPERTIES.CARRIER:               on IP4.ADDRESS[1]:                         192.168.184.137/24 IP4.GATEWAY:                            192.168.184.2 IP4.ROUTE[1]:                           dst = 169.254.0.0/16, nh = 0.0.0.0, mt = 1000 IP4.DNS[1]:                             192.168.184.2 IP4.DOMAIN[1]:                          localdomain IP4.WINS[1]:                            192.168.184.2 IP6.ADDRESS[1]:                         fe80::a674:307d:1fa:57c1/64 IP6.GATEWAY:                            -- swarm-lb0@ubuntu:~$ 

gpasswd -a $USER docker | newgrp docker # login to new group without logout

gpasswd -a $USER docker # add current user to group docker newgrp docker # login to new group without logout

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - || date | vi -

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - adds gpg key into apt-key add as argument date | vi - #opens vi with current date

mail notification service is down httpd

#!/bin/sh SERVICE='httpd' if ps ax | grep -v grep | grep $SERVICE > /dev/null then echo "$SERVICE service running, everything is fine" else echo "$SERVICE is not running" echo "$SERVICE is not running!" | mail -s "$SERVICE down" root fi

How do I add text to the beginning of a file in Bash?

echo 'task goes here' | cat - todo . txt > temp && mv temp todo . txt or sed - i '1s/^/task goes here\n/' todo . txt or sed - i '1itask goes here' todo . txt

CHECK!!! bash course

bash course exit 0 read -a export VAR not subshell profile subshells bashrc user top kill pid telnet 0 cat -vet 0 stdin, 1 stdout, 2 stderr pipeline stdout-)stdin grep -E '[A-Z][a-z]+\b' file.txt grep -l n c grep ^...$ #find any 3 chars sed  -r s c a y I p whereis fdisk -l udev daemon chntpw su - vs su su - logs you in completely as root, whereas su makes it so you are pretending to be root. mount -o remount,rw / parted -k gpt gui uefi partitions )2tb (part 2) partitions primary extended logical have compiled your own kernel at some point, know how to trace syscalls, understand TCP, care about the difference between sysvinit/runit/systemd, etc man 7 signal trap kill term int substitution operators ${VAR:-word} pattern matching ${BLA#bla*} optarg man test pncopy strace -c ls hup vs kill var/log/messages centos rpm qa in ubuntu yum update apt.get update redhat satelite ubuntu landscape tools for deployment root.system.people sudo su ls --help show options cd equal cd ,,~ rm -rf

sed http://www.pement.org/sed/sed1line.txt

http://www.pement.org/sed/sed1line.txt

sed -i 's/fea/asd/g' hello.txt | sed "/bam/ s/foo/bar/" # Replace foo with bar on lines contain 'bam' | sed -i '1s/^/head2\n/' file1

sed - i 's/fea/asd/g' hello . txt g:  Global s:  substitute -i  : realtime works with file --- sed "/bam/ s/foo/bar/" # Replace foo with bar only on lines that contain 'bam'. #add text at the begining sed -i '1s/^/head2\n/' file1