New to command line Linux

posted by SwiftCloudHosting in Linux Administration
584

If you happen to be new with a command line environment and don't know where to get started here is a quick list of different useful Linux commands!

pwd (Print working directory)

Whenever you open a Linux command line shell, you start at a directory. This is your working directory until you change to some other directory. To see the complete path of your working directory, always use the pwd (print working directory) command.

[root@swf userFTP]# pwd
/home/userFTP

cd (Change directory)

This command is used to navigate through different directories and change your current directory

[root@swf userFTP]# pwd
/home/userFTP
[root@swf userFTP]# cd ..
[root@swf home]# pwd
/home

ls (list segments)

Using the ls command, you can display the contents of your current directory. Many options are available with the ls command. The ls command, by itself, does not show all the files in the directory. Some files are hidden files (also called dot files) and can only be seen with an additional option specified to the ls command.

[root@swf home]# ls -a
. .. userFTP

chmod (Change Mode)

On Linux, there is a set of rules for each file which defines who can access that file, and how they can access it. These rules are called file permissions or file modes. The command name chmod is used to define the way a file can be accessed.

read  write  execute

[root@swf home]# chmod u=rwx,g=rx,o=x myfile.txt
[root@swf home]# ls -l myfile.txt
-rwxr-x--x 1 root root 0 Mar 10 10:35 myfile.txt
[root@swf home]# chmod 777 myfile.txt
[root@swf home]# ls -l myfile.txt
-rwxrwxrwx 1 root root 0 Mar 10 10:35 myfile.txt

ifconfig (interface configurator)

Common uses for ifconfig include setting the IP and netmask of a network interface and disabling or enabling an interface. If we run a ifconfig without any parameters we will see something like this:

[root@swf home]# ifconfig
lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:30 errors:0 dropped:0 overruns:0 frame:0
          TX packets:30 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:2067 (2.0 KiB)  TX bytes:2067 (2.0 KiB)
venet0    Link encap:UNSPEC  HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00  
          inet addr:127.0.0.1  P-t-P:127.0.0.1  Bcast:0.0.0.0  Mask:255.255.255.255
          UP BROADCAST POINTOPOINT RUNNING NOARP  MTU:1500  Metric:1
          RX packets:94024 errors:0 dropped:0 overruns:0 frame:0
          TX packets:68025 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:92827396 (88.5 MiB)  TX bytes:7384531 (7.0 MiB)
venet0:0  Link encap:UNSPEC  HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00  
          inet addr:167.114.106.85  P-t-P:167.114.106.85  Bcast:167.114.106.85  Mask:255.255.255.255
          UP BROADCAST POINTOPOINT RUNNING NOARP  MTU:1500  Metric:1

ping (Packet Internet Groper)

This command is the best way to test connectivity between two nodes. Whether it is Local Area Network or Wide Area Network. You can ping host name of IP address using below command.

[root@swf home]# ping swiftcloudhosting.com
PING swiftcloudhosting.com (23.92.65.52) 56(84) bytes of data.
64 bytes from 23.92.65.52: icmp_seq=1 ttl=64 time=49.1 ms
64 bytes from 23.92.65.52: icmp_seq=2 ttl=64 time=49.1 ms
64 bytes from 23.92.65.52: icmp_seq=3 ttl=64 time=49.1 ms
64 bytes from 23.92.65.52: icmp_seq=4 ttl=64 time=49.1 ms

traceroute

This command is a uttility tool that records the route, the gateway at each hop, throught the internet between your computer and a specified destination computer. It also calculates the amounts of time between each hops and displays it. This tool is handy to understand where the problems are in the Internet network and for getting a detailed sense of internet itself.

[root@swf home]# traceroute swiftcloudhosting.com
traceroute to swiftcloudhosting.com (23.92.65.52), 30 hops max, 60 byte packets
 1  ns509259.ip-198-27-82.net (198.27.82.41)  0.021 ms  0.007 ms  0.006 ms
 2  bhs-g2-6k.qc.ca (198.27.73.15)  2.161 ms  2.170 ms  2.168 ms
 3  * * *
 4  * * *
 5  * * *
 6  ae-3-80.edge1.Washington4.Level3.net (4.69.149.143)  49.673 ms ae-1-60.edge1.Washington4.Level3.net (4.69.149.15)  35.617 ms ae-3-80.edge1.Washington4.Level3.net (4.69.149.143)  14.215 ms

Netstat (Network Statistic)

Netstat is a common networking command line tool, it provides information and statistique about protocols in use. It lists out all the tcp, udp socket connections and the unix socket connections. So by verifying an open port 80 you can confirm if a web server is running on the system or not.

[root@swf home]# netstat -s
Ip:
    94338 total packets received
    0 forwarded
    0 incoming packets discarded
    94338 incoming packets delivered
    68278 requests sent out
Tcp:
    16 active connections openings
    1547 passive connection openings
    23 failed connection attempts
    322 connection resets received
    1 connections established
    89522 segments received
    62650 segments send out
    679 segments retransmited
    1 bad segments received.
    496 resets sent
Udp:
    4459 packets received
    156 packets to unknown port received.
    0 packet receive errors
    4754 packets sent

THE CHEAPEST AND MOST VALUABLE VPSTRY AND FEEL THE DIFFERENCE FOR AS LOW AS $8.45/m

Powered by WHMCompleteSolution

© COPYRIGHT 2018 SWIFT CLOUD HOSTING, ALL RIGHTS RESERVED.
SWIFT CLOUD HOSTING RELIABLE, VALUABLE AND PERFORMANT VIRTUAL PRIVATE SERVER IS OWNED AND OPERATED BY JC HOLDINGS.
BY USING THIS SITE, YOU AGREE ON SWIFT CLOUD HOSTING VPS SERVER SOLUTION TERMS OF SERVICE.