Networking/Computing Tips/Tricks

Rate this content:
5 of 5 - 2 votes
Thank you for rating this article.
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 brand new to it, there is a lot to learn.
 
This article is like a mini starter course on Linux. I have built this mini course by condensing some oldie but goodie 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 20.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 Virtual Machine.  
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.
Look here (https://ubuntu.com/tutorials/how-to-run-ubuntu-desktop-on-a-virtual-machine-using-virtualbox#1-overview) for how to install Ubuntu as a virtual machine using free Virtual Box.

Once you have your Ubuntu Linux machine ready, let's begin this mini-course.

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
 
Now that you have begun to learn Libux, check out our other Linux content here: https://www.cellstream.com/component/search/?searchword=Linux&searchphrase=all&Itemid=119
 
I hope you find this mini course/article and its content helpful.  Comments are welcomed below.  If you would like to see more articles like this, please support us by clicking the patron link where you will receive free bonus access to courses and more, or simply buying us a cup of coffee!, and all comments are welcome! 
 
 

Add comment

Submit

Did you learn something?
Did I save you time? 

Buy me a coffeeBuy me a coffee!

Find by Tag

5G Networks 6LoWLAN 6LoWPAN 802.11 802.11ah 802.11ax 802.11ay 802.11az ACL Addressing Analysis Ansible Architecture ARP Assessment AToM Backup Bandwidth BGP Bibliography Biography Briefings CBRS CellStream Cellular Central Office Cheat Sheet Chrome Cisco Clock Cloud Computer Consulting CPI Data Center Data Networking Decryption DHCPv4 DHCPv6 Display Filter DNS Documentation ECMP EIGRP Ethernet Flipping the Certification Model Follow Me Fragmentation Git GNS3 Google GQUIC Hands-On History Home Network HTTPS ICMP ICMPv6 IEEE 802.11p IEEE 802.15.4 In A Day Internet IOS Classic IoT IPv4 IPv6 L2 Switch L2VPN L3VPN LDP Learning Services Linux LLN Logging LoL M-BGP MAC MAC OSx Macro Microsoft mininet Monitoring Monitor Mode MPLS Multicast Name Resolution Netflow NetMon netsh Networking Network Science nmap Npcap nslookup Online Learning Online School OpenFlow OSPF OSPFv2 OSPFv3 OSX Parrot Passwords pcap pcap-ng PIM Ping Policy Port Mirror POTS POTS to Pipes PPP Profile Profiles Programming Project Management Python QoS QUIC Requirements RFC RIP Routing RPL RSVP SAS SDN Security Self Certification Service Provider Small Business Smartport SONET Span Port SSH SSL Subnetting T-Shark TCP TCP/IP Telco Telecom 101 Telecommunications Telnet Terminal TLS Tools Traceroute Traffic Analysis Traffic Engineering Training Travel Troubleshooting Tunnel Utility Video Virtualbox Virtualization Voice VoIP VXLAN Webex Wi-Fi Wi-Fi 4 Wi-Fi 5 Wi-Fi 6 Wi-Fi 6/6E Windows Wireless Wireless 5G Wireshark Wireshark Tip WLAN ZigBee Zoom

Twitter Feed