Category Archives: Linux

InitV and systemd parctical notes

Nicely written reference https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/7/html/System_Administrators_Guide/sect-Managing_Services_with_systemd-Unit_Files.html Short cheat shit List services: # chkconfig –list # systemctl list-units This will show any unit that systemd loaded or attempted to load, regardless of its current state on the system. # systemctl list-units –all # systemctl list-units –all –state=inactive # systemctl list-units –type=service Since systemd will only read units that it […]

Read more

Sudoers syntax

http://unix.stackexchange.com/questions/18877/what-is-the-proper-sudoers-syntax-to-add-a-user In the following sudo entry: superadm ALL=(ALL) ALL there are four fields: The first one specifies a user that will be granted privileges for some command(s). The second one is rarely used. It’s a list of hostnames on which this sudo entry will be effective. On standard setups only one host is relevant (localhost) […]

Read more

vmstat output explained

Table 11-4 Output From the vmstat Command Category Field Name Description procs Reports on the following: r The number of kernel threads in the dispatch queue b The number of blocked kernel threads that are waiting for resources w The number of swapped out LWPs that are waiting for processing resources to finish memory Reports on usage of […]

Read more

Parallel and xargs commands

1. Decypher gpg files find ./ -name “*.gpg” |  while read OUT; do echo ${OUT%.*}; done | /usr/local/bin/parallel -P 15 gpg –output {}  –decrypt {}.gpg 2. Unzip files find ./ -name “*.gz” |  /usr/local/bin/parallel -P 15 gunzip {} \; unzip into different directory: find ./ -name “*.gz” | while read OUT; do echo ${OUT%.*}; done […]

Read more

Static routing

Solaris: route add host 192.168.1.12 192.168.1.1 Solaris, route persistent between reboots: route -p add host 192.168.1.12 192.168.1.1 Linux RedHat: route add -host 192.168.1.12 gw 192.168.1.1 Linux persistent routes: /etc/sysconfig/network-scripts/route-XXX where XXX – name of interface http://www.softpanorama.org/Net/Netutils/route.shtml Q1. Which command manipulates the routing table ? A: route  Q2: Command to add a route to server1 via router1: […]

Read more

NTP client troubleshooting

http://support.f5.com/kb/en-us/solutions/public/10000/200/sol10240.html   Observe the output with references on the fields presented in the previous table. Example of a successful NTP peer server query If the local ntpd process can communicate or attempts to communicate with a declared NTP peer server, the output from the ntpq command appears similar to the following example: # ntpq -np remote           […]

Read more

SSH forwarding where to look

Where to look if X11 forwarding does not work   1. In /etc/ssh/sshd_config should be the options: AddressFamily inet (if the host is ipv4 only) X11Forwarding yes 2. in /etc/hosts shold be 127.0.0.1 localhost (if the host is ipv4 only) 3. try debugging ssh session: /usr/sbin/sshd -d -p 222 4. DISPLAY environment variable should be […]

Read more

Multihost ssh tools

http://www.fabfile.org/   Fabric is a Python (2.5-2.7) library and command-line tool for streamlining the use of SSH for application deployment or systems administration tasks. It provides a basic suite of operations for executing local or remote shell commands (normally or via sudo) and uploading/downloading files, as well as auxiliary functionality such as prompting the running […]

Read more

Disk benchmarking

Здесь вкратце описано как связаны между собой основные параметры диска http://www.databasejournal.com/features/oracle/article.php/3731961/Measuring-Disk-IO151A-Vendor-View.htm С помощью Oracle’овой утилиты Orion можно померить максимальную производительность дисков Документация здесь: http://download.oracle.com/otn/utilities_drivers/orion/Orion_Users_Guide.pdf Если указывать в файле *.lun список raw-devices, то запускать нужно из-под root’а. Другая возможность – давать список файлов на нужном устройстве. Тогда достаточно прав владельца файла. 1. создаем файл с названием […]

Read more

Some bash examples

Название файла без пути: $(basename $file) Меняем расширение у всех файлов в директории: for f in *.arc; do mv “$f” “`basename “$f” .arc`.dbf”; done; Название файла без расширения: Use ${x%.*} to remove everything after a dot or ${x%%.*} to remove everything after the first dot. Example: $ x=”/foo/fizzbuzz.bar.quux” $ y=${x%.*} $ echo $y /foo/fizzbuzz.bar $ […]

Read more

NTP

To check if ntpd is configured: $chkconfig –list ntpd ntpd            0:off   1:off   2:on    3:on    4:on    5:on    6:off Install and configure ntpd if not configured: #yum install ntp ntpdate ntp-doc #chkconfig ntpd on Initial time synchronization: #ntpdate <ntp-srv-IP-address> Configure ntpd: Into /etc/ntpd.conf add NTP server and comment out default servers if necessary: server <…> Start ntpd: […]

Read more