Linux – transfer file securely between your windows PC to Linux PC using Putty’s PSCP.exe

Step 1: Go to PuTTY web site and download pscp.exe. Save the file in C:/pscp folder for later use.


Step 2: Open Windows CMD window and move to C:/pscp folder and also place your file to transfer to this folder as well.

Volume in drive C is Windows
Volume Serial Number is 9AA5-6C7B

Directory of C:\PSCP

02/20/2019 11:53 AM <DIR> .
02/20/2019 11:53 AM <DIR> ..
02/20/2019 11:33 AM 611,456 openssh-client_7.6p1-4ubuntu0.2_amd64.deb
02/20/2019 11:42 AM 626,744 pscp.exe
2 File(s) 1,238,200 bytes
2 Dir(s) 2,275,581,952 bytes free


Step 3:  From your Windows PC, run psc file transfer command

“pscp file_name user_ID@Linux_Server_IP:/Directory_name1/Directory_name2” to start the file transfer. In this example, I am transferring ssh-client to Ubuntu 18 server.

C:\PSCP>pscp openssh-client_7.6p1-4ubuntu0.2_amd64.deb bchoi@
Using keyboard-interactive authentication.
Password: ********
openssh-client_7.6p1-4ubu | 597 kB | 298.6 kB/s | ETA: 00:00:00 | 100%



Step 4: On Linux Server/PC, check that the file has been transferred correctly.

root@nu-aut-wow-01:/home/bchoi# pwd
root@nu-aut-wow-01:/home/bchoi# ls
colorama-0.3.9-py2.py3-none-any.whl xlrd-1.1.0-py2.py3-none-any.whl
colorama-0.3.9.tar.gz xlrd-1.1.0.tar.gz


Step 5 (Optional): To reverse and get the file from Linux to Windows’ PC do the following.


C:\PSCP>pscp bchoi@ ./
Using keyboard-interactive authentication.





Linux – Add a new user & Enable SSH login

Add a new user and enable SSH login.

1. Add user

#adduser jdoe
Set password prompts:
Enter new UNIX password: ********
Retype new UNIX password: ********
passwd: password updated successfully
2. User information prompts:
Changing the user information for username
Enter the new value, or press ENTER for the default
Full Name []: John Doe
Room Number []: 101
Work Phone []: 61 2 9898 1234
Home Phone []: 61 414 123 456
Other []:
Is the information correct? [Y/n] Y
3. Optionally, make the user to sudoer group.
#usermod -aG sudo jdoe
4. Test sudo user account
#su – jdoe

username$ sudo ls -la /root
5. Update sshd_config file and then restart sshd

#nano /etc/ssh/sshd_config

… [omitted]

LoginGraceTime 180
PermitRootLogin yes
AllowUsers bchoi jdoe…

… [omitted]


Restart SSH Services:
# systemctl restart sshd

Linux 101 – Enable Telnet on Ubuntu Server

Step 1. Install telnet

apt-get install xinetd telnetd

Step 2. Edit /etc/inetd.conf using nano. Add this to the blank file.

telnet stream tcp nowait telnetd /usr/sbin/tcpd /usr/sbin/in.telnetd
Step 3. Edit /etc/xinetd.conf

# Simple configuration file for xinetd
# Some defaults, and include /etc/xinetd.d/


# Please note that you need a log_type line to be able to use log_on_success
# and log_on_failure. The default is the following :
# log_type = SYSLOG daemon info
instances = 60
log_type =SYSLOG authpriv
log_on_success = HOST PID
log_on_failure = HOST
cps = 25 30
Step 4. Restart telnet server

/etc/init.d/xinetd restart

Fundamentals of Quality of Service (QoS) (Notes):

Thanks to all time best Cisco instructor Kevin Willis for sharing his video on Youtube! I watched his video to revist QoS fundamentals and re-consolidate previous knowledge. KW, you’re a Legend!


 “Quality of Service is a managed unfairness.”


  1. Learn QoS Mechanisms
  • QoS is like a tool box with various number of tools, not just one thing
  1. Understand QoS Markings
  • how do we mark different traffics
  1. Demystify Weighted RED
  • Weighted Random Early Detection
  1. Select Appropriate Queuing
  • g.) LAN is running 1GB but WAN network is only 10mb, how does the router handle the 100:1 speed ratio,
  • High priority traffic such as Real-time streaming video or voice vs download/gaming traffic?
  1. Explain the ‘Token bucket’
  2. Configure QoS using MQC


Fundamentals of Quality of Service (QoS):

 “Quality of Service is a managed unfairness.”

  1. Learn QoS Mechanisms

If you have all different application fighting for the same bandwidth, you have to decide based on the characteristics of each traffic. Know what the applications are and what the business needs are.


10Gb links everywhere, no big deal to have a QoS.

Even within LAN, on high speed network the aggregation point becomes a bottleneck.



IntServ =  RSVP (Resource Reservation Protocol). Sometimes called “hard-QoS”. Bandwidth is pinned-up (reserved) so a certain traffic can use on demand. These days, we rarely see IntServ in use due to inflexible nation of this QoS mechanism.

DiffServ = Differentiated Service. Router will differentiate different traffic types. Put different traffic types for different class. Create no more than 11 different traffic (if everyone is special, nobody is special) <<<Cisco recommendation.

Best effort = FIFO, first in firs served. No QoS enabled.


Common QoS Mechanisms – QoS is not a single tool that you just activate. QoS is a collection of tools.

  1. Classification and Marking

e.g.) Boarding pass for an airline – priority marking on boarding pass

Cisco tells us to classify your traffic into no more than 11 network traffic types. Classify and mark the traffic as early as possible on your network, changing bits on the header. Routers and switches can look at the header information and quickly decide whether to forward/drop packets, so the decision becomes really fast. Use access lists (NBAR) to do this. Once the traffic is classified, put the marking on it. However, classification and marking alone does not do anything.


  1. Queuing

E.g.) 1GB or 10GB Switch network traffics coming into router network with 10MB link out. If we had FIFO. We only have a limited amount of memory to queue all traffics, once the queue buckets fill-up, the excess traffics will start dropping overflowing from the single bucket. So to make this more efficient based on different traffic’s characteristics, this bucket can be sub-divided into a few smaller buckets, then different traffic can fill-up and use different buckets with varying priorities.

Mark the traffics and it can be put into different buckets. e.g.) VoIP goes into different bucket vs Best effort traffic. Typically VoIP traffic gets DSCP 46 (Differentiated Services Code Point). If VoIP is marked with a DSCP of 46, then put this traffic into one bucket. Everybody else can go into the other bucket. This is called queue separation. Even though the Best Effort buckets gets full and start dropping packets, the VoIP bucket will fill up occasionally and will not get full and impacted by the Best Effort bucket’s performance.


Cisco has many tools to help us on how to manage queues and dictate emptying these queues. Different Queue mechanisms supported on Cisco IOS?  Weighted Fair Queuing, Class-based weighted Queuing, Low Latency Queuing, Priority queuing, Custom Queuing, In the real world scenario, Class-based weighted Queuing and Low Latency Queuing are most often used.

The beauty of queuing is that it can protect certain traffic just simply separating different traffics into different buckets.


  1. Congestion Avoidance

RED – Random Early Detection, drop random traffic for the good of many.


  1. Policing and Shaping

Traffic conditioners

Policing – sets speed limit, if some packet is trying to transmit more than allowed, policing drops any exceeding traffic packet and these traffics must be retransmitted if they are TCP packets. If this is UDP packets, there is no retransmission.

Shaping – also sets speed limit, but softer, not enough bandwidth, buffer (delay) the packets and then send them off.


  1. Link Efficiency

Not as important as it used to be as we have higher WAN links these days.

  1. Link Fragmentation and Interleaving (LFI) = Sometime on the network on a slow speed link (56kbps link), there is a 1500byte data packet queued up and tiny voice packet has been queued up behind this packet. 214ms to send 1500bytes through 56kbps link.


Voice packet speed requirement:

<150ms transmission speed is OK.

>150ms = will start to get bad

>200ms = really get bad


E.g.) Analogy, metaphor – Caught at Traffic light and three trailer truck (Data packet) is in front of your sports car (voice packet). Fragment the 3 trailers and send them, but the sports car can swivel through them and get passed through. One issue: due to fragmentation, now you have three headers on each of the trailer, so increased header size. @768kbps (WAN link), if you are sending voice over IP, if less than 768kbps speed, use of LFI will help. If 768kbps or more, do not use LFI, it will hurt the network more than helping.


  1. Compression – sending the same amount of data using less bandwidth

The main use on today’s network is ‘RTP header compression’

RTP (Real Time Protocol) is a L4 protocol, depending on what sort of codec we use, the size of the payload could be 20 bytes, add L3 IP header + L4 UDP header + L4 RTP header = 40 bytes of header alone. Your header is 2 times the size of your payload. The payload to header ratio is 1:2. Turn on RTP header compression on the router interface. The routers looks at the voice packets arriving on its interface and see the commonalities between every packets in the same communication, it seems like every packet has the same destination IP address, same source and destination port IDs, why are we sending the same information multiple times? On each end routers, keep the copy of this information and send much smaller header (either 2 bytes or 4 bytes. 4 bytes have checksum. Generally on Cisco devices, it will use 2 bytes). The 2 bytes header contains the session context identifier (CID) which differentiates one voice conversation with another voice conversation. At the far end router, the router uses CID to identify the voice traffic and put the cached header copies onto the coming in traffic and send out to the LAN network.


 2. Understand QoS Markings


L2 marking = Class of Service (CoS)

ISL = not used

IEEE802.1Q = 4 bits added, (3 bits = 8 values (0-7) bits.)


6 and 7 bits = reserved for network use

cos 5 = voice traffic

DSCP Values:

CS (Class Selector)

Issue: Only layer 2 marking, if it goes out through a Router, it gets written over.  So, this has to be rewritten at L4 header using Type of Service (TOS) Bytes.


We can use three left bits; we can use IP Precedence (CoS matching only gives 6 classes of traffic as we cannot use 6 & 7 bits as in CoS). IP Precedence is not scalable. We now use DSCP using 6 bits in ToS byte – 0-63 DSCP values can be used. The 64 values gave too many options, so ITF decided to define commonly used DSCP values to set up certain standards.


ITF preselected 21 names Per Hop Behaviours (PHB), we can use the number or names that corresponds to ITF names.



 DSCP/PHB Value for Enterprise traffics.

사용자 지정 20


  1. Demystify Weighted RED

 Random Early Detection (RED)

사용자 지정 16

When we get to certain level (Min. threshold), start introducing the possibility of dropping. As it moves up and hit the Max Threshold, the chances of dropping packets get bigger.

 사용자 지정 17

 MPD = Mark Probability Denominator

 Cisco IOS already has MPD values, but this can be manipulated. The following is WRED profiles suggested by Cisco.

 사용자 지정 18


Explicit Congestion Notification (ECN)

Uses the 7th bit in ToS Byte for ECT and 8th bit for CE.

The receding router can mark the ECT and CE bits to binary 1’s and ask the other router to slow down. Otherwise, the packets gets dropped and then the TCP slow-start will kick-in (TCP windowing concept, where the window size is doubled continuously until it reaches threshold value and it drops down and TCP slow-start kicks in.)

 사용자 지정 19



  1. Select Appropriate Queuing


사용자 지정 25

Cisco recommends us to use no more than 11 traffic classes, but one class already is created by default, “class-default”.  Catch-all traffic class, so we can use 12 classes of traffic.

  • class-default uses FIFO.
  • CB-WFQ – during the time of congestion when QoS kicks in, give minimum of x Mbps of bandwidth, but give more if more bandwidth is available.
  • LLQ (priority) queue – during the time of congestion, give up to 3Mbps of bandwidth, but nor more that 3Mbps.

E.g.) Car pool lane or bus lane – if you have more passengers, you have rights to use the special lane, but still needs to keep the speed-limit.


  1. Explain the ‘Token bucket’

Using Frame-relay network, speed of 128kbps.

How do you send data at the half the rate of the line speed? of if the full line speed is 128kbps, send at 64kbps speed. Use the analogy of car traveling at 100km/h to reach 50kms in 0.5 hours.

Send & stop, send & stop, this is how the policing and shaping does its magic.

 사용자 지정 26


  1. Configure QoS using MQC

고정된 영역 1

고정된 영역 2

고정된 영역 3


고정된 영역 4




MQC Demo

QoS configuration is a 3 steps process:


Step 1: Create Class-maps


R1#conf t

Enter configuration commands, one per line.  End with CNTL/Z.

R1(config)#class-map ?

WORD       class-map name

match-all  Logical-AND all matching statements under this classmap

match-any  Logical-OR all matching statements under this classmap

type       Configure CPL Class Map


R1(config)#class-map match-any EMAIL

R1(config-cmap)#match protocol pop3

R1(config-cmap)#match protocol imap

R1(config-cmap)#match protocol exchange

R1(config-cmap)#match protocol smtp



R1(config)#class-map VOICE

R1(config-cmap)#match protocol rtp ?

audio             Match voice packets

in-app-hierarchy  Match protocol in transport hierarchy

payload-type      Match an explicit PT

potentially       Match protocol, and all potentiall traffic

video             Match video packets


R1(config-cmap)#match protocol rtp audio





R1(config)#class-map match-any WEB

R1(config-cmap)#match protocol http

R1(config-cmap)#match protocol secure-http



R1(config)#class-map SCAVENGER

R1(config-cmap)#match protocol bitt

R1(config-cmap)#match protocol bittorrent



R1#show class-map

Class Map match-any class-default (id 0)

Match any


Class Map match-any EMAIL (id 1)

Match protocol pop3

Match protocol imap

Match protocol exchange

Match protocol smtp


Class Map match-any WEB (id 3)

Match protocol http

Match protocol secure-http


Class Map match-all VOICE (id 2)

Match protocol rtp audio


Class Map match-all SCAVENGER (id 4)

Match protocol bittorrent



Step 2: Create Policy-maps

R1(config)#policy-map QOS-LAB1


Policy-map configuration commands:

class        policy criteria

description  Policy-Map description

exit         Exit from policy-map configuration mode

no           Negate or set default values of a command

R1(config-pmap)#class EMAIL


Policy-map class configuration commands:

admit            Admit the request for

bandwidth        Bandwidth

compression      Activate Compression

drop             Drop all packets

exit             Exit from class action configuration mode

fair-queue       Enable Flow-based Fair Queuing in this Class

flow             Flow subcommands

log              Log IPv4 and ARP packets

measure          Measure

netflow-sampler  NetFlow action

no               Negate or set default values of a command

police           Police

priority         Strict Scheduling Priority for this Class

queue-limit      Queue Max Threshold for Tail Drop

random-detect    Enable Random Early Detection as drop policy

service-policy   Configure QoS Service Policy

set              Set QoS values

shape            Traffic Shaping


R1(config-pmap-c)#set dscp af13

R1(config-pmap-c)#bandwidth 512 <<<give this command first before giving ‘random-detect’ command


R1(config-pmap-c)#random-detect ?

atm-clp-based                   Enable atm-clp-based WRED as drop policy

clp                             parameters for each clp value

cos                             parameters for each cos value

cos-based                       Enable cos-class-based WRED as drop policy

discard-class                   parameters for each discard-class value

discard-class-based             Enable discard-class-based WRED as drop


dscp                            parameters for each dscp value

dscp-based                      Enable dscp-based WRED as drop policy

ecn                             explicit congestion notification

exponential-weighting-constant  weight for mean queue depth calculation

precedence                      parameters for each precedence value

precedence-based                Enable precedence-based WRED as drop policy



R1(config-pmap-c)#random-detect dscp-based <<<default is using cos, this command enables dscp based WRED

R1(config-pmap-c)#random-detect ecn <<<turns on ECN


R1(config-pmap)#class VOICE

R1(config-pmap-c)#priority 256 <<<Enabled LLQ, go first

R1(config-pmap-c)#random-detect dscp-based <<<Since voice traffic is RTP encapsulated in UDP, TCP slow-start will not help us. So, no need to use ECN bits. No need to use WRED.

Must deconfigure priority in this class before issuing this command


R1(config-pmap)#class WEB

R1(config-pmap-c)#bandwidth 768


R1(config-pmap)#class SCAVENGER

R1(config-pmap-c)#police 128000 <<<Set the maximum bandwidth using Policing. This is in bps (bits) not Bps (Bytes).




R1#show policy-map

Policy Map QOS-LAB1


set dscp af13

bandwidth 512 (kbps)


priority 256 (kbps)

Class WEB

bandwidth 768 (kbps)


police cir 128000 bc 4000

conform-action transmit

exceed-action drop


#Marking only can be done on the inbound traffic.

#Shaping can only be applied to outbound traffic.

#Policing can be applied to either directions.


R1#conf t

R1(config)#int gi0/0

R1(config-if)#service-policy output QOS-LAB1 <<<Apply configuration to outgoing traffic



R1#show policy-map interface gi0/0



Service-policy output: QOS-LAB1


queue stats for all priority classes:


queue limit 64 packets

(queue depth/total drops/no-buffer drops) 0/0/0

(pkts output/bytes output) 0/0


Class-map: EMAIL (match-any)

0 packets, 0 bytes

5 minute offered rate 0000 bps, drop rate 0000 bps

Match: protocol pop3

0 packets, 0 bytes

5 minute rate 0 bps

Match: protocol imap

0 packets, 0 bytes

5 minute rate 0 bps

Match: protocol exchange

0 packets, 0 bytes

5 minute rate 0 bps

Match: protocol smtp

0 packets, 0 bytes

5 minute rate 0 bps


queue limit 64 packets

(queue depth/total drops/no-buffer drops) 0/0/0

(pkts output/bytes output) 0/0

QoS Set

dscp af13

Packets marked 0

bandwidth 512 kbps


Class-map: VOICE (match-all)

0 packets, 0 bytes

5 minute offered rate 0000 bps, drop rate 0000 bps

Match: protocol rtp audio

Priority: 256 kbps, burst bytes 6400, b/w exceed drops: 0



Class-map: WEB (match-any)

0 packets, 0 bytes

5 minute offered rate 0000 bps, drop rate 0000 bps

Match: protocol http

0 packets, 0 bytes

5 minute rate 0 bps

Match: protocol secure-http

0 packets, 0 bytes

5 minute rate 0 bps


queue limit 64 packets

(queue depth/total drops/no-buffer drops) 0/0/0

(pkts output/bytes output) 0/0

bandwidth 768 kbps


Class-map: SCAVENGER (match-all)

0 packets, 0 bytes

5 minute offered rate 0000 bps, drop rate 0000 bps

Match: protocol bittorrent


cir 128000 bps, bc 4000 bytes

conformed 0 packets, 0 bytes; actions:


exceeded 0 packets, 0 bytes; actions:


conformed 0000 bps, exceeded 0000 bps


Class-map: class-default (match-any)

3 packets, 180 bytes

5 minute offered rate 0000 bps, drop rate 0000 bps

Match: any


queue limit 64 packets

(queue depth/total drops/no-buffer drops) 0/0/0

(pkts output/bytes output) 3/180


Top 10 useful Linux commands – for your first Linux job interview

  1. How to check Linux Kernel version of a system?

[root@localhost /]# uname

-a = all

-v = version

-r = release

[root@localhost /]# uname -a
Linux localhost.localdomain 3.10.0-862.el7.x86_64 #1 SMP Wed Mar 21 18:14:51 EDT 2018 x86_64 x86_64 x86_64 GNU/Linux
[root@localhost /]# uname -v
#1 SMP Wed Mar 21 18:14:51 EDT 2018
[root@localhost /]# uname -r


2. How to check your system’s current IP address?

Old method – “ifconfig

2-1 ifconfig

New method – “if addr show‘ or “if addr

2-1 ip addr show


3. How to check for free disk space?

df = disk free

-ah = all + human readable

so, use “df -ah

3. df -ah


4. How to manage services on a system?

Old method: service [service_name] status

New method: systemctl status [service_name]

sshd status example shown below:

service sshd status

4-1 service sshd status

systemctl status sshd

4-2 systemctl status sshd


5. How to check the size of a directory’s contents on disk?

du = disk use

-sh = short

so, use “du -sh [directory_path]

5 du -sh

*note: if you use ‘du var’ without -sh handle, it will display all files in that directory.


6. How to check open ports on a Linux server?

netstat = lists all ports, could be too much information, so have to trim it down.

6 netstat


nestat -tulpn

-t = TCP, -u = UDP, -l = Listening, -p = program, -n = numeric


6 netstat -tulpn

*note: ‘netstat -tupln’ has to run with a privilege to display the programs.


7. How to check CPU usage of a given process?

ps aux | grep [service_name]

top = shows top processes utilised, updates every 5 seconds.


ps aux | grep sshd

7-1 ps aux grep sshd


7-2 top

*You can also install ‘htop’ and see more graphical based process utilisation.


8. How to mount a new volume? Mounting a device.

ls /mnt = devices are usually mounted under root directory called ‘mnt’

mount /dev/sda2 /mnt = mount sda2 device to mnt mounting point

mount = list all mounted devices

To check what devices got mounted on boot-up, use ‘less /etc/fstab’


9. Finding out something you don’t know?

Use ‘man‘ pages.

[command] –help


10. What do you do when you cannot find an answer in a man page?

Search using Google, stack overflow, etc. on the internet.



4. Install and configure NTP server in Red Hat/Centos 7.5 Linux

NTP (Network Time Protocol) is a protocol which runs over UDP port 123. NTP synchronise clients’ time and date with a master server. Within Enterprise Networking environment, to provide a reliable time service, an NTP server should have a minimum NTP stratum of 5 or less.

Step 1: Install and configure NTP daemon

sudo yum install ntp


Step 2: Check and adjust time zone

  1. timedatectl
  2. timedatectl list-timezones <<<to list and find time zones
  3. timedatectl set-timezone Australia/Sydney

Step 3: Enable and start ntpd service

sudo systemctl enable ntpd

sudo systemctl start ntpd


Step 4: Check basic NTP functionality



ntpq –p


Step 5: Check NTP configuration under /etc/ntp.conf

more /etc/ntp.conf