DEV Community

Ravi Shankar
Ravi Shankar

Posted on

Basic Linux Commands

sort

sort command is used to sort the data inside the file.

If we don't mention any options it will sort the lines which begin with

  • Empty Lines
  • Numerical Values
  • Alphabetical Order

Syntax of sort command

sort [ options ] filename
Enter fullscreen mode Exit fullscreen mode

These are some of the options used along with sort command
-b         To ignore leading spaces
-d         To sort in dictionary order
-f         Converts all lower case to upper case while comparing
-r         To reverse sort
-M       To sort according to months

Examples

sort -b filename
sort -db filename
Enter fullscreen mode Exit fullscreen mode

 

date

date command is used to display the date and time on the system and also to set the date and time.

Syntax of date command

date [OPTION]... [+FORMAT]
date [-u|--utc|--universal] [MMDDhhmm[[CC]YY][.ss]]
Enter fullscreen mode Exit fullscreen mode

Example
To print the date and time

date
Enter fullscreen mode Exit fullscreen mode

Options with date command
-s         To set the date and time
-d         To display time described by input string

 

tree

tree command displays the directories and files in a tree like structure.

Syntax

tree [options]
Enter fullscreen mode Exit fullscreen mode

Example
To print the directories and files in tree like structure

tree
Enter fullscreen mode Exit fullscreen mode

Options used with tree
-a         All files are listed
-d         Only directories are listed
-f         Prints the full path for each file
-o         Output to given file istead of stdout

 

wc

wc command is used to count newlines, words and characters in a file

Syntax

wc [OPTION] [FILE]
Enter fullscreen mode Exit fullscreen mode

Example
To print the word count in a file

wc filename
Enter fullscreen mode Exit fullscreen mode

Options used with wc command
-w         Prints word counts
-c         Prints character counts
-b         Prints byte counts
-l         Prints new line counts

 

ping

ping command is used to check network connection between host and server/host.
Along with ping we use ip address of a host or url.

Syntax

ping [options] <destination>
Enter fullscreen mode Exit fullscreen mode

Options
-c         Stop after count replies
-l         Send preload number of packages while waiting replies
-s         Use size as number of bytes to be sent
-W       Time to wait for response

Example

ping -c 3 www.facebook.com
Enter fullscreen mode Exit fullscreen mode

 

ifconfig

Ifconfig is used to configure the kernel-resident network interfaces.
It is used at boot time to set up interfaces as necessary.
After that, it is usually only needed when debugging or when system tuning is needed.

Syntax

ifconfig [-a] [-s] [interface]
Enter fullscreen mode Exit fullscreen mode

Options
-a         Displays all the interfaces available
-s         Displays short list instead of details

Example

ifconfig -s
Enter fullscreen mode Exit fullscreen mode

 

ssh

ssh is a program for logging into a remote machine and for executing commands on a remote machine.
It is intended to provide secure encrypted communications between two untrusted hosts over an insecure network.

Syntax

ssh username host
Enter fullscreen mode Exit fullscreen mode
  • username represents the account that is being accessed on the host.
  • host refers to the machine which can be a computer or a router that is being accessed.

Top comments (0)