Networking/Computing Tips/Tricks

So often we use Linux as a virtual machine or even as a test or capture system.  If you are a little rusty on Linux, or new to it, there is a lot to learn.
 
This article has condensed some great HakTip videos from the folks at Hak5 along with out own notes on using Linux.
 
Let's start with what Linux build to get if you want to follow along.  In the videos below, the Hak5 presenter appears to have used Ubuntu (www.ubuntu.com) for this article.  The download of the .ISO file is free.  It is also big.  The 16.04 desktop version is about 1.4 Gigs.  Once the .ISO is downloaded, then you have the choice of creating a bootable USB stick, installing on a stand alone machine, or installing the system as a VM.  Look here (http://www.omgubuntu.co.uk/2016/04/how-to-create-a-bootable-ubuntu-usb-on-windows-mac-and-linux) for how to create a bootable USB on Windows, MAC, or Linux machine.
 
Once you have your Ubuntu Linux machine ready, let's learn how to use the Linux Terminal.

Start here:

 

Here is a summary of the commands presented:
  • date - displays date
  • cal - displays the calendar
  • df - displays used and available space on the disk system
  • free - displays free space
  • pwd - print working directory
  • cd - change directory, a series of options was shown
  • ls - list contents of a directory, and several options were shown
  • not mentioned was the 'dir' command which shows all files in the current diretory
  • clear - clears the terminal screen
  • adding '--help' on the back of any command displays the linux help for that command

Linux Terminal 101 - File Manipulation

 

Here is a summary of the commands presented:
  • mkdir - creates a new directory
  • rmdir - removes a directory (this was not mentioned in the video)
  • cp - copy a file, a source to a destination
  • mv - move - you can move a file to a directory or to a copy of the original file
  • rm - removes a file or directory (be careful!)
  • do not forget the '--help' on these commands to see many options available 

Linux Terminal 101 - Wildcards, Hard Links, and Symbolic Links 

Here is a summary of the commands presented:
  • examples start at about the 2 minute mark
  • using a "*" in a command is a wildcard that matches any characters - such as 'ls *'
  • using a "?" in a command is a wildcard that matches any specific character in that position - such as 'ls Test?' will match all files that start with "Test" and have a single character following that word.
  • using a bracketed letter or sequence shows all items with that sequence.  For example in a directory with Test1, Test2, Test3 and Test4 files, if you enter 'ls Test[1]' only the Test1 file will be shown.
  • putting a '!' in the brackets is the same as "not".  For example in a directory with Test1, Test2, Test3 and Test4 files, if you enter 'ls Test[!1]' all but the Test1 file will be shown.
  • using double brackets '[[:st]]' creates a way to find anything matching the characters used
  • ln - link - creates a hard link to a file or directory.
  • do not forget the '--help' on these commands to see many options available 
 

Linux Terminal 101 - Filenames, History, and Shortcuts 

Here is a summary of the commands presented:
  • history - shows history of commands
  • history | less - shows history on a page by page basis (space moves forward a page, q quits)
  • !! - reruns last command used, and !5 would run the 5th command in the history (5 commands ago). But, as shown, most of us simply use the up arrow.  The up and down arrow allows you to navigate the history
  • the tab key is the autocomplete 
 

Linux Terminal 101 - type, which, and apropos

Here is a summary of the commands presented:
  • type - tells what type of command or term is in Linux
  • which - tells which area in Linux the command is referenced from
  • man - internal manual pages for Linux
  • apropos - searches the manual for all instances of a term
  • whatis - asks Linux what a term/command is
  • info - finds information on a term/command in the manual
 

Linux Terminal 101 - Create your own command with alias

Here is a summary of the commands presented:
  • the ';' allows you to string together commands
  • alias - allows you to create commands or stringed commands - as shown use 'type' and the alias name to display the command contents.  Remember that alias commands are not saved.
  • unalias - removes an alias
  • To save aliases for future use, you have to edit the .bashrc file.
  • Here is a nice alias: alias upd='sudo apt-get update;sudo apt-get upgrade'
 

Linux Terminal 101 - I/O Redirection

Here is a summary of the commands presented:
  • normal output goes to 'stdout'
  • errors go out to 'stderr'
  • the command Shannon used was 'ls -l /usr/bin > ls-output.txt'  The redirections essentially performed by the ">".
  • the second command used was  'ls -l /usr/bin >> ls-output.txt' prepends the output onto prior file.
 

Linux Terminal 101 - Redirecting Standard Terminal Errors

Here is a summary of the commands presented:
  • remember errors go out to 'stderr'
  • the command Shannon used was 'ls -l /bin/usr 2> ls-error.txt'  The redirections if the errors essentially performed by the "2>".
  • the second command used was  'ls -l /bin/usr > ls-output.txt 2>&1'
  • the third command used was  l's -l /bin/usr &> ls-output.txt'
  • We don't reccomend the last command she shows - errors are important - but here it is:  'ls -l /bin/usr 2> /dev/null' 
 

Linux Terminal 101 - Using CAT with Standard Inputs

Here is a summary of the commands presented:
  • cat is like 'type' in DOS
  • cat lists the contents of a file: 'cat ls-output.txt'
  • cat Test* > JoinedTest would join all Test files in order.
  • Creating a text file with cat: cat >file.txt and then start typing the text you want to see in the file.
 

Linux Terminal 101 - Grep and Pipes

Here is a summary of the commands presented:
  • '|' is the pipe command (look above your backslash key) means the output of the left of the pipe is redirected to whatever is on the right, and you can create a chain of multiple pipes.
  • Example 1: ls -l /usr/bin | less
  • Example 2: ls /bin /usr/bin | sort | less
  • Example 3: ls /bin /usr/bin | sort | uniq | less
  • Example 4: ls /bin /usr/bin | sort | uniq -d | less
  • Example 5: wc trust.txt
  • Example 6: ls /bin /usr/bin | sort | uniq | wc -l
  • grep finds files and text with certain patterns.
  • Example 7: ls /bin /usr/bin | sort | uniq | grep zip
  • Example 8: head -n 5 trust.txt
  • Example 9: tail -n 5 trust.txt
  • Example 10: ls /usr/bin | tail -n 5
  • Example 11: ls /usr/bin | tee ls.txt | grep zip
 
More to come!
 
 
 

Comments powered by CComment

The nicest thing you can do is use these inks to support us!  Thank you!

Support our research!  Buy me a coffee :)

Support our research. Become a Patron!

Find by Tag

4G Networks 5G Networks 6in4 6LoWLAN 6LoWPAN 802.11 802.11ah 802.11ax 802.11ay 802.11az Addressing Analysis Ansible Architecture ARP AToM BGP Bloom's Taxonomy Broadband Cable cat CBRS CellStream Cellular Central Office Cheat Sheet Chrome Cisco Cloud Coloring Rules Computer Consulting CPI Customer Support Data Center Data Networking DHCPv6 DNS Docker Documentation Dublin-Traceroute dumpcap ECMP Ethernet Ethics Fragmentation G-MPLS Git GNS3 Google GQUIC Hands-On History Home Network ICMP ICMPv6 IEEE 802.11p IEEE 802.15.4 Interface Control Internet IoT IPsec IPv4 IPv6 IS-IS L2VPN L3VPN LDP Linux LLN LoL M-BGP MAC MAC OSx Macro Microsoft mininet Monitoring MPLS MTU Multicast My Room Name Resolution Netcat Netmiko NetMon netsh Networking Network Science nmap Npcap Online School OpenFlow OSPF OSPFv2 OSPFv3 OSX OTT Paris-Traceroute Parrot PIM pktmon PMTU Policy POTS POTS to Pipes PPP Profile Programming Project Management Protocol 41 PW3E Python QoS QUIC Remote Desktop Requirements RIP Routing RPL RSVP Rural SAS SDN Security Service Provider Small Business SONET Speed SS7 SSH SSL Subnetting SYSCTL T-Shark TCP TCP/IP Telco Telecom 101 Telecommunications Telephone termshark TLS Tools Traceroute Traffic Engineering Training Travel Tunnel Ubuntu Utility Video Virtualbox Virtualization VoIP VRF VXLAN Webex WEP Wi-Fi Wi-Fi 4 Wi-Fi 5 Wi-Fi 6 Wi-Fi 6/6E Windows Winpcap Wireless Wireless 5G Wireshark Wireshark Tip WLAN WPA2 Zenmap ZigBee Zoom

Support us by clicking:

Twitter Feed