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 * del current dir
rm -rf / dont do

its not possible to create hardlink to directory or other device, only symbolic link

through inode we got access to data blocks

usermod -Ga group1 user1 ( G override s previous group)
id user

!gre repeat last grep 
/etc/shadow !! user locked

chage

etc.login.defs - default password age

chown chgrp change user or group owner

without execute permission you cannot get to directory
without read you cannot ls directory

chmod +x file
chmod u=rw,g-w,o+x file

daemon - systemctl,

jobs
dd if=dev zero of dev null
ctrl z - stop job temporarily

jobs
bg fg
ctrl c terminate job
pstree


top 
1.01 bad
wa disk write

ctrl l clean
kill 15 vs 9 in top
default process priority 20, increase by 5

tools used for deployment
ubuntu landscape,redhat satelite, puppet, chef

cttl alt f1 f2 switch terminals

elinks text browser

man -k apropos
man -k time / grep 1
/usr/share/doc pam,rsyslog


man 7 glob
ls -d l*

mail -s subj root < .

grep hi * 2>/dev/tty6

find / -name "*.rpm" > rpm.results 2> /dev/null

ls > files
sort <files >files.sorted

ls -d *[0-9]* doesnt show dir content

which whereis locate updatedb

file etc.tar
tar is used for backups
tar czvf file.tgz

tar + gzip

tar xvf file.tar -C /tmp
tar xvf /root/etc.tar -C / etc/wgetrc

cp /etc/[aef]* /tmp

grep -iR  file * 2>/dev/nu search in directories

sed 2q file #show first 2 lines
sed -n '2p' file #same

sed -n /^root/p etc.passwd
grep '^root' etc.passwd

sed -i 's/old/new/g' file

ctrl alt f1,2 open virtual terminal

ssh-keygen
ssh-copy-id -p 2022 user@host
scp ipaddress:port

etc.ssh
ssh_config client
sshd_config server


etc.shadow !! user disabled

etc passwd.
gecos field used to identify the user(sales department)

by default rhel uses private groups

etc.login.defs
etc.default.useradd
etc.skel

ldap
dc=com,dc=rhel,cn=server

ldd login

etc.pam.d

special permissions
suid 4000
guid 2000
sticky 1000

setfacl -R -m g:sales:rx dir
setfacl -m d:g:sales:rx dir
getfacl dir

ip addr flush
ip addr show
ip a

ip route show
#temp
ip route add 20.0.0.0/8 via 192.0.0.1
ip addr add dev env33 192.8.8.8/24


ip -s link

net settings
/etc/sysconfig/network-scripts
vim ifcfg-ens33

etc/hostname is used now by linux instead of etc/sysconf

network manager gets conf from sysconf and pushes to
etc/resolve.conf #dont change here

nmcli,nmtui
after changing nmtui do systemctl restart NetworkManager

nmcli con down ems32; nmcli com up ems33

dig
nmap
netstat
traceroute

ip -s link

jobs are related to current shell environment
ctrl z
jobs
bg #runs last job
sleep 600 & # run in background
fg 1
ctrl c terminate job

w shows terminal

ps fax parent process

free -m #m stands mb

top show cpus press 1
cachd is used for files .disk speed

use sigterm 15 over sigkil 9

killall sleep . all processes with name dd

nohup
https://www.google.com.ua/amp/s/www.cyberciti.biz/tips/nohup-execute-commands-after-you-exit-from-a-shell-prompt.html/amp

name nohup stands for "no hangup." The hangup (HUP) signal, which is normally sent to a process to inform it that the user has logged off (or "hung up"), is intercepted by nohup, allowing the process to continue running.

 standard input is a terminal, nohup redirects it from /dev/null. If standard output is a terminal, append output to "nohup.out" if possible, "$HOME/nohup.out" otherwise. If standard error is a terminal, redirect it to standard output. To save output to file FILE, use "nohup COMMAND > FILE".

by default process priority 20

nice -20 to 19
pgrep -a dd

renice -n 5 pid

yum meta package handler

cd /etc/yum.repos.d
vim myrepo.repo
[myrepo]
name=myrepo
baseurl=file:///repo
gpgcheck=0

yum repolist
yum search ftp
yum list all
yum list installed

yum whatprovides */semanage
yum removd bash

all installed software via rpm database

which chronyd
rpm -qf /sbin/chronyd
rpm -ql chronyd
rpm -qc chrony #config files involved
rpm -qd chrony #documentation
rpm -qa #all installed packages
rpm -q --scripts httpd #install postinstall script.security

yum localinstall packagename 

repoquery

dd if=/dev/sr0 of=/root/rhel.iso # command to create iso

cat /etc/crontab

cd /etc/cron.daily

crontab -e or put file to /etc/crontab.d

systemctl list-units -t service (ubuntu>14)

atq
atrm
/var/spool/at
/var/log/messages

systemctl daemon-reload

____
daemon-reload¶

Reload the systemd manager configuration. This will rerun all generators (see systemd.generator(7)), reload all unit files, and recreate the entire dependency tree. While the daemon is being reloaded, all sockets systemd listens on behalf of user configuration will stay accessible.

This command should not be confused with the reload command.

_____
cat /proc/partitions


1mb partition meta data

in fdisk 1mb 1000kb, 1mib 1024kb

partitions are created with fdisk
file system is created with mkfs.xxx

mount /dev/sdb1 /mnt
/mnt used for testing mounting
mount - shows mounted devices
mount ! grep ^dev
umount /mnt

blkid - show devices and uuid

mount LABEL=myfs /mount

classic way to mount filesystem automatically is to use etc/fstab

mount -a 
mounts what wasnt mounted

journalctl -xb
journalctl -f


rhel var.messsges var.secure
ubuntu var.syslog

ubuntu
systemctl status rsyslog

etc.rsyslog.cong info.warn.error

in rhel7 there are no run levrls but systemd targets

ln -sf 
-------
useradd linda
cd /home/linda
touch rootsfile
su - linda
rm -f rootsfile

if user has write permissions on directory,he can delete files
-------
dont change unit files in usrbin folder,copy to etc
dont need to copy back from etc to usrbin
__


locate updatedb

hard link can only be created if it refers to a file in the same file system. This is because inodes are unique to a file system. Links that cross file system boundaries must be symbolic links.

https://en.m.wikipedia.org/wiki/Doors_(computing)

ls -s -h

firewalls
ufw and iptables ubuntu
firewalld and iptables rhel
firewalld runtime config,not persistent
to add in runtime and persistent
firewall-cmd --add-service ldap --permanent
--list-all
--get-services

repquota

disown -r
remove running jobs

compgen -c list of commands

rpm -e sendmail #uninstall

show the status of all Linux kernel modules currently loaded:
lsmod

Comments

Popular posts from this blog

HAproxy logging

teamcity Automatic Agent Start under Linux

NFS mount add in fstab _netdev instead of default | firewall-cmd --list-all