Chmod Command Examples In Linux / UNIX

The chmod command changes the access mode of one file or multiple files.

Following are the symbolic representation of three different roles:

  • u is for user,
  • g is for group,
  • and o is for others.

Following are the symbolic representation of three different permissions:

  • r is for read permission,
  • w is for write permission,
  • x is for execute permission.

Following are few examples on how to use the symbolic representation on chmod command. Continue reading

Netstat Command Examples In Linux / UNIX

Netstat command displays various network related information such as network connections, routing tables, interface statistics, masquerade connections, multicast memberships etc.,

In this article, let us review 10 practical unix netstat command examples.

1. List All Ports (both listening and non listening ports)

List all ports using netstat -a

# netstat -a | more
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address           Foreign Address         State
tcp        0      0 localhost:30037         *:*                     LISTEN
udp        0      0 *:bootpc                *:*                                

Active UNIX domain sockets (servers and established)
Proto RefCnt Flags       Type       State         I-Node   Path
unix  2      [ ACC ]     STREAM     LISTENING     6135     /tmp/.X11-unix/X0
unix  2      [ ACC ]     STREAM     LISTENING     5140     /var/run/acpid.socket

Continue reading

Grep Command Examples In Linux / UNIX

The grep command is used to search text or searches the given file for lines containing a match to the given strings or words. By default, grep displays the matching lines. Use grep to search for lines of text that match one or many regular expressions, and outputs only the matching lines. grep is considered as one of the most useful commands on Unix and other Linux operating systems.

First create the following demo_file that will be used in the examples below to demonstrate grep command.

$ cat demo_file
THIS LINE IS THE 1ST UPPER CASE LINE IN THIS FILE.
this line is the 1st lower case line in this file.
This Line Has All Its First Character Of The Word With Upper Case.

Two lines above this line is empty.
And this is the last line.

Continue reading

Du Command Examples In Linux / UNIX

Linux du command is used for summarizing the disk usage in terms of file size. It can be used with folders to get the total disk usage. This article provides some examples on how to use du command effectively.

All the du examples shown here are executed on a directory containing the following contents:

$ ls
linuxKernel  redhat  testfile.txt  ubuntu

Continue reading