UNIX – What is a sticky bit ?

History The sticky bit was first introduced in 1974 within the UNIX operating system. Its purpose was to instruct the operating system to place the process into swap once completed. Thus reducing the startup time of the process during further executions. However nowdays this usage is obsolete. Usage Instead, the sticky bit is now set … Read more

VIM – How do I make the width of a single TAB only 4 spaces wide ?

In this extremely short article we will provide you with the steps required to make the width of a single TAB only 4 spaces wide.This especially useful when using Visual Mode within VIM , in that you can indent large portions of text. Steps Within your ~/.vimrc file add the following lines. set shiftwidth=4   ” … Read more

Why does my scp file transfer fail but no error message is shown ?

Issue When using scp to copy a file the file fails to transfer, however there is no error message. Solution This issue can occur due echo commands within your .bashrc and how the scp program handles the output from these commands. This is a known bug within scp which can be viewed here. To resolve this … Read more

How do I tab multiple lines within VI ?

Within this article we will looking at the steps required to tab multiple lines within VI.This feature is great for ensuring readability, when editing indent based languages such as Python or just programming in general. Steps Press “<SHIFT> + v” to enter VISUAL LINE mode. Select the text you wish to indent but using either … Read more

Unix Mount Commands

Samba mount -t cifs //[Windows IP]/[Share] /root/folder/ -o user=[username],pass=[password],nocase BSD mount -t cd9660 /dev/`mdconfig -a -t vnode -f discimg.iso` /cdrom Solaris mkdir -p /cdrom/unnamed_cdrom ; mount -F hsfs -o ro `ls -al /dev/sr* | awk ‘{print “/dev/” $1 1}’` /cdrom/unnamed_cdrom

Basic Regular Expressions (UNIX)

Basic Regular Expressions ^abc BOL abc at the beginning of the line abc$ EOL abc at the end of the line A* Any amount of characters matches any sqec or more of A`s i.e A, AAAAAA, AA, AAAAAAAAAA . Any 1 Character Any Character .* Any Characters Any Characters a[a-z0-9]c Range Between a and c … Read more

Google Advanced Search Operators

“google example” phrase Pages containing the exact phrase “google example” example  -word exclude Pages containing the word example but not the word “word” example site:www.example.com site Pages containing example within website www.example.com ~example similar Pages containing words similar to example example filetype:ppt filetype Documents containing the word example and are ppt extenstions example|google either Pages … Read more

A Look into Tcpdump

Tcpdump is a packet capture for the Linux command line. This is by no means a full guide but a quick overview of some of the main commands. The syntax below will capture all traffic with IP address of 172.16.1.1 and and IP in the network 172.16.1.0/24 with a port of udp/53. This will write … Read more

UNIX – Tcpdump

Tcpdump is a packet capture for the Linux command line. This is by no means a full guide but a quick overview of some of the main commands. The syntax below will capture all traffic with IP address of 172.16.1.1 and and IP in the network 172.16.1.0/24 with a port of udp/53. This will write … Read more

Common Sed Examples

Below are some of the common uses and commands for sed that I have come across over the years, Find and Replace sed -i ‘s|arp|/sbin/arp|g’ /etc/init.d/proxyarp Find and Delete sed -e ‘/^$/d’ file.txt Remove Multiple words This will remove word, word1, or word2 from the file input.txt sed ‘s/word\|word1\|word2//g’ input.txt Change the first instance on … Read more

UNIX – Add an interface Redhat / Fedora

To add a interface you need to do the following,   1. Confirm what the mac address is by running ifconfig -a  2. Then edit the relevant script , which can be found at /etc/sysconfig/network-scripts/ifcfg-eth0. The script can be ifcfg-eth1, ifcfg-eth2 etc etc.  3. And it should look something like this (for a static IP), … Read more

UNIX – TCP/IP Stack Modifications

Solaris Prevent DoS /usr/sbin/ndd -set /dev/tcp tcp_conn_req_max_q 1024/usr/sbin/ndd -set /dev/tcp tcp_conn_req_max_q0 2048/usr/sbin/ndd -set /dev/tcp tcp_time_wait_interval 60000/usr/sbin/ndd -set /dev/ip ip_respond_to_echo_broadcast 0/usr/sbin/ndd -set /dev/ip ip_forward_directed_broadcasts 0 Disable redirects /usr/sbin/ndd -set /dev/ip ip_ignore_redirect 1/usr/sbin/ndd -set /dev/ip ip_send_redirects 0 Disable Source routing /usr/sbin/ndd -set /dev/ip ip_forward_src_routed 0 Linux Kernal 2.2 Prevent DoS /sbin/sysctl -w net.ipv4.tcp_max_syn_backlog=1280/sbin/sysctl -w net.ipv4.vs.timeout_timewait=60/sbin/sysctl -w net.ipv4.icmp_echo_ignore_broadcasts=1 … Read more

UNIX – IP Forwarding

IP forwarding is the process of forwarding packets from one network to another. Below shows the necessary steps to enable/disable IP forwarding. Solaris Enable IP Forwarding ndd -set /dev/ip ip_forwarding 1 Disable IP forwarding ndd -set /dev/ip ip_forwarding 0 Check the status ndd -get /dev/ip ip_forwarding Linux Kernel If the output is 1 IP forwarding … Read more

UNIX – Process State Codes

O – On processor — the process is executing on the CPU in either user or system mode. R – Runnable — the process is on a run queue and is running or runnable. S – Sleeping — the process is waiting for a I/O event to complete. Z – zombie — process, terminated but … Read more

UNIX – Mounting a partition in Linux

In order to mount a hard drive we need to add an entry to the file /etc/fstab. This entry will allow us to not lose our drive mounting after a system reboot. /dev/sdb1       /mypartition       ext3    defaults        0       0 Then to action the changes run the following command, root@server:/# mount -a Finally check that the drive … Read more

UNIX – Recursive Grep

Below will grep for all files containing the word ssh at the beginning of the line. The BOL symol is ^.  grep -r ^ssh /etc

UNIX – Syslog – Quick Guide

Here’s a quick overview of Syslog, there’s much more to it and you can find tons more information in the links at the bottom of the page. Syslog stands for the System Log protocol. It allows for the sending and receiving of event messages and alerts across an IP network. Operating on either UDP or … Read more

Want to become a UNIX expert?

Here is our hand-picked selection of the best courses you can find online:
UNIX Administration Fundamentals
Vim Masterclass
and our recommended certification practice exams:
AlphaPrep Practice Tests - Free Trial