ntpq -pn

[email protected]:~# ntpq -pn remote refid st t when poll reach delay offset jitter ============================================================================== - 3 u 30 64 1 1.182 -0.029 0.000 + .GOOG. 1 u 20 64 1 52.571 0.660 0.240 + .GOOG. 1 u 20 64 1 36.033 1.016 0.176 - .GOOG. 1 u 24 64 1 140.712 1.154 0.286 * […]

FUCK: syntax error in /etc/sudoers file

[email protected]:~$ sudo >>> /etc/sudoers: syntax error near line 33 <<< sudo: parse error in /etc/sudoers near line 33 sudo: no valid sudoers sources found, quitting sudo: unable to initialize policy plugin   [email protected]:~$ pkexec visudo -f /etc/sudoers ==== AUTHENTICATING FOR org.freedesktop.policykit.exec === Authentication is needed to run `/usr/sbin/visudo’ as the super user Multiple identities can […]

sed tips

sed -i ‘s/fengo/dressholic/g’ *  sed -i ‘s/Fengo/Dressholic/g’ *  search folders for file type recurisvely and replace text in file find . -type f -exec sed -i.bak “s/fengo/dressholic/g” {} \;  find . -type f -exec sed -i.bak “s/Fengo/Dressholic/g” {} \;  delete files in folders with extension find . -name “*.bak*” -type f -delete

In Unix, how do I find a user’s UID or GID?

In Unix, how do I find a user’s UID or GID? To find a user’s UID or GID in Unix, use the id command. To find a specific user’s UID, at the Unix prompt, enter: id -u username Replace username with the appropriate user’s username. To find a user’s GID, at the Unix prompt, enter: […]

infinite loop dd benchmark stress test script

X=1 while : do echo $X echo “write sync” time sh -c “dd if=/dev/zero of=/mnt/sda/ddfile bs=8k count=4000000 && sync” echo “write flush” time sh -c “dd if=/dev/zero of=/mnt/sda/ddfile bs=8k count=2000000” echo “read” time sh -c “dd if=/mnt/sda/ddfile of=/dev/null bs=8k” ((X+=1)) done

Change file and folder permissions

find . -type f -exec chmod 644 {} ; find . -type d -exec chmod 755 {} ; below works for ubuntu To change permission of only files under a specified directory. [email protected]:/home/user$ sudo find /path/to/someDirectory -type f -print0 | xargs -0 sudo chmod 644 [email protected]:/home/user$ ls -l total 3 -rw-r–r–  1 user user 0 Nov 19 20:13 file1 drwxrwxrwx  2 user user 4096 Nov […]

passwd: Authentication token manipulation error

Centos [[email protected] ~]# passwd Changing password for user root. New UNIX password: Retype new UNIX password: passwd: Authentication token manipulation error solved [[email protected] ~]# /usr/sbin/useradd aa useradd: unable to open password file [[email protected] ~]# chattr -i /etc/passwd [[email protected] ~]# /usr/sbin/useradd aa useradd: cannot open shadow password file [[email protected] ~]# lsattr /etc/passwd ————– /etc/passwd [[email protected] ~]# […]

Radius login with Ubuntu

sudo apt-get install libpam-radius-auth edit $ sudo vim /etc/pam_radius_auth.conf find other-server    other-secret       3 change to 192.168.x.x secretkey 3 Edit your /etc/pam.d/sshd file and add the line: auth       sufficient  pam_radius_auth.so Just above: # Standard Un*x authentication. @include common-auth had to update firewall config and configure radius to accept auths from this IP using this to upload […]

How to Setup Apache2 (HTTPD) with FastCGI and PHP on CentOS/RHEL 6/5

  yum install mod_fastcgi Loaded plugins: fastestmirror, replace Setting up Install Process Loading mirror speeds from cached hostfile * base: mirrors.psychz.net * epel: mirror.prgmr.com * extras: mirrors.xmission.com * rpmforge: mirror.webnx.com * updates: mirrors.easynews.com * webtatic: us-east.repo.webtatic.com Resolving Dependencies –> Running transaction check —> Package mod_fastcgi.x86_64 0:2.4.6-2.el5.rf will be installed –> Finished Dependency Resolution Dependencies Resolved […]

Updating servers cuz of glibc vulnerability

Ghost is a vulnerability in glibc that attackers can use against only a handful of applications right now to remotely run executable code and gain control of a Linux server. The vulnerability is a heap-based buffer overflow and affects all Linux systems, according to experts, and has been present in the glibc code since 2000. […]

Speedtest has a cli – speedtest_cli.py

When you want to run speedtest from a linux server you can try cli version speedtest_cli.py http://ubuntuserverguide.com/2014/01/how-to-test-internet-connection-speed-using-speedtest-cli-on-ubuntu-server.html

Remove /home with LVM and add to /

  Make sure you have no data in /home. If you do then move it or copy it somewhere else. You will lose all data in the Logical Volume. umount /home lvremove /dev/mapper/vg_ubuntu_home lvdisplay lvextend -L+#G /dev/mapper/vg_ubuntu_root resize2fs /dev/mapper/vg_ubuntu_root df -h

Yum update – glibc conflict

This should be resolved now. The problem was that there were both 32 bit and 64 bit packages for glibc. I removed the 32 bit packages with the following: rpm -e –justdb –nodeps glibc.i686 glibc-devel.i386 And then the command that failed previously was able to succeed: yum -y install automake19 gettext libstdc++.x86_64 libpng-devel openssl libpng-dev […]

CentOS 7 uses XFS now! How to Expand/extend your LVM

To my surprise CentOS 7 is now using XFS. I was trying to extend the LVM using my usual guide from VMware, resize2fs command spits out thi error: resize2fs: Bad magic number in super-block while trying to open /dev/centos/root Couldn’t find valid filesystem superblock use xfs_grow instead http://xmodulo.com/2014/09/manage-lvm-volumes-centos-rhel-7-system-storage-manager.html

RHEL6: Cool PAM Tricks – Logging Terminal Keystokes

Pam-original-cooking-spray-72450This is a neat and very useful trick that I learned today. Lets say that you want to be able to monitor and log all keystrokes that are typed as root. This is particularly useful as normally you can only log when a user uses sudo to run a command. If the user has the […]

mtr unable to get raw sockets – mac os x

$ mtr yahoo.com mtr: unable to get raw sockets. $ sudo chmod 4755 /usr/local/sbin/mtr $ sudo chown root:wheel /usr/local/sbin/mtr $ sudo chmod u+s /usr/local/sbin/mtr create file $ vi ~/.bash_profile alias mtr=/usr/local/sbin/mtr  

smtp relay cpanel using a smarthost

We make the following changes for outbound scanning. Edit /etc/exim.conf Look for two instances of: driver = dnslookup under dk_lookuphost: and lookuphost: Comment both instances and add two instances of driver = manualroute route_list = * barracuda.outgoing.hostname so it’ll look something like this: dk_lookuphost: #driver = dnslookup driver = manualroute route_list = * barracuda.outgoing.hostname lookuphost: […]

Setting up a permanent ssh tunnel using autossh

Since the original website is offline, I’m hosting the content here now —> Setting up a permanent SSH tunnel between 2 servers Greeting everyone, Today, I’ll show you how to setup an easy and permanent SSH tunnel that auto reconnect in case of failure between two linux servers. It may happen (for your own personal […]

ssh reverse tunnels

http://unix.stackexchange.com/questions/46235/how-does-reverse-ssh-tunneling-work http://askubuntu.com/questions/50064/reverse-port-tunnelling

help – /boot is full

if /boot is full try removing some old kernels Getting Started 1. You can check your current used kernel with this command: uname -r 2. To find a list of all installed kernels on your system, run this command: dpkg –list | grep linux-image 3. To remove all unused kernels, run now this command: sudo […]

notes – what is “> /dev/null 2>&1”

http://www.xaprb.com/blog/2006/06/06/what-does-devnull-21-mean/ Output redirection The greater-thans (>) in commands like these redirect the program’s output somewhere. In this case, something is being redirected into /dev/null, and something is being redirected into &1. Standard in, out, and error There are three standard sources of input and output for a program. Standard input usually comes from the keyboard […]

syslog headache

http://www.johnandcailin.com/blog/john/how-setup-real-time-email-notification-critical-syslog-events http://www.softpanorama.org/Logs/syslog.shtml http://linux.byexamples.com/archives/412/syslog-sending-log-from-remote-servers-to-syslog-daemon/

too many fuser processes and high cpu

too many fuser processes i guess i ran into this bug https://bugs.launchpad.net/ubuntu/+source/php5/+bug/876387 fixed by adding ppa:ondrej/php5 and updating psmisc https://launchpad.net/~ondrej/+archive/php5