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
- 7 -> rwx
- 6 -> rw
- 5 -> rx
- 4 -> r
- 3 -> wx
- 2 -> w
- 1 -> x
- 0 -> none
[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:22.214.171.124 P-t-P:126.96.36.199 Bcast:188.8.131.52 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 (184.108.40.206) 56(84) bytes of data. 64 bytes from 220.127.116.11: icmp_seq=1 ttl=64 time=49.1 ms 64 bytes from 18.104.22.168: icmp_seq=2 ttl=64 time=49.1 ms 64 bytes from 22.214.171.124: icmp_seq=3 ttl=64 time=49.1 ms 64 bytes from 126.96.36.199: icmp_seq=4 ttl=64 time=49.1 ms
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 (188.8.131.52), 30 hops max, 60 byte packets 1 ns509259.ip-198-27-82.net (184.108.40.206) 0.021 ms 0.007 ms 0.006 ms 2 bhs-g2-6k.qc.ca (220.127.116.11) 2.161 ms 2.170 ms 2.168 ms 3 * * * 4 * * * 5 * * * 6 ae-3-80.edge1.Washington4.Level3.net (18.104.22.168) 49.673 ms ae-1-60.edge1.Washington4.Level3.net (22.214.171.124) 35.617 ms ae-3-80.edge1.Washington4.Level3.net (126.96.36.199) 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