Linux Commands Projects 4 and 5
ls -l Documents
-rw-r--r-- 1 student student 2222 Apr 3 04:18 file1 Shows the contents of the Documents directory without having to change directories to the Documents directory.
Three files that appeared when you typed ls -a What is special about their file name?
.bash_aliases .bash_history holds a history of the Bash commands that have been typed .bash_logout holds a script that runs when the current shell is closed n *nix, files that begin with a dot (.) are considered hidden and normally should not be visible.
cd /home/student and pwd output
/home/student
pwd
/home/student/Documents/dirname
Head command
A Linux command that displays the first 10 lines of a text file.
traceroute
A program that shows the route a packet takes across the Internet a utility application that monitors the network path of packet data sent to a remote computer tracert
nslookup
A utility that is used to test and troubleshoot domain name servers. 50.17.144.162 student@kali:~$ nslookup www.cnu.edu Server: 10.1.160.2 Address: 10.1.160.2#53 Non-authoritative answer: Name: www.cnu.edu Address: 50.17.144.162
cd /
Command to change to the root directory.
arp -a
Consists of a list of IP addresses that have recently been used to contact remote computers on the same LAN, with the associated MAC address (or Ethernet address) 10.1.128.2 - 0e:ae:45:38:55:62 10.1.128.1 - 0e:ae:45:38:55:62 Identifies the Ethernet addresses that have been used by your computer.
>>
Create a file if one does not exist. If a file does exist, it adds to the original contents of a file.
whoami
Display the current username. student.
cal -d 2020-12
Displays a calendar of the current month. Allows you to display a specific month and year.
ifconfig -a
Displays a list of active and inactive network interfaces. 10.1.172.165 An example for a computer with a primary IP addresses of 10.1.172.165 (in dotted decimal notation) is shown below: eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 9001 inet 10.1.172.165 netmask 255.255.240.0 broadcast 10.1.175.255
date
Displays the current date in the following format: Fri Apr 3 03:34:36 UTC 2020
cal
Displays the current month in a calendar format. The current day will be highlighted.
Socket
File that allows bi-directional communication between two processes on the same system
Named pipe (p)
File that allows processes to communicate by putting data into a FIFO (first in, first out) file.
Block device file (b)
File that is used to hold blocks of data being transferred from a device, such as a hard drive or USB device.
Character file (c)
File used to hold data being transferred from a device such as a keyboard or mouse, one character at a time.
ls -l
File1 is no longer in the student home directory.
.bash_history
Holds a history of the Bash commands that have been typed.
.bash_logout
Holds a script that runs when the current shell is closed.
.bashrc
Holds a script that runs whenever a shell is launched for the current user
ls -l
Lists all files and directories in long format. It gives back several columns wich correspond to: File Permissions: drwxr-xr-x Number of hardlinks: 2 File owner: root File group: root File size: 4096 Last Modification Date: Mar 9 11:49 File name: modprobe.d drwxr-xr-x 2 root root 4096 Mar 9 11:49 modprobe.d Allows you to look through the file system.
exit
Logs off from the system, closes the session, and closes the terminal.
cat file1
Output: Some text More text Allows you to see the contents of a file.
tail file1
Output: 3 months of calendar
Help [command-name]
Provides specific information for any CLI command.
dig -x
Reverse DNS lookup. Allows users to specify the IP address instead of a domain name to perform a reverse DNS lookup.
-c
Send x number of packets
ping -c5 127.0.0.1
Sends 5 packets of data to the IP address to test % packet loss and speed.
nmap -sn 10.1.172.165/20
Sends a ping packet to each IP address and listen for replies to identify active hosts on the subnet.
Hard links
Show how many links or shortcuts to the same inode exist
history
Shows a listing of all of the commands that used in your session.
head file1
Some text More text And now a calendar...
cal -y 2021 >> file1
The -y option outputs the entire year calendar for whatever year is entered as an argument to the command The words "And now a calendar..." and the 2021 year calendar was appended to the end of the file.
The chmod command can be used on a file by:
The file owner and root -rw-r----- 1 student student 21734 Apr 7 15:22 casts.csv Owner has read, and write permissions and group has read permissions and world has no permissions
ls -l
There is nothing in the documents directory
cd
Used to change directories in the file system.
ifconfig
Used to display information about the loop back interface. lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536 inet 127.0.0.1 netmask 255.0.0.0 This example information shows that some options have been set (73) that the interface is connected (UP), it is running in loop back (LOOPBACK) and that it is currently operational (RUNNING). The internet (IP) network address is 127.0.0.1 (in dotted decimal notation) and the IP netmask is 255.0.0.0 (in decimal).
uname
Used to find out which operating system the VM is running. Provides information about the operating system being used
uname -a
Used to force uname to be a bit more specific. Adds an "option" to the call. In Unix, this is done by adding a "-Something" (i.e., a dash and a few letters) to the original command call. displays all of the information about the linux system (i.e. kernal name, system hostname, release number, version number, architecture, processor type, platform, system & information). Linux kali 4.15.0-kali3-amd64 #1 SMP Debian 4.15.17-1kali1 (2018-04-25) x86_64 GNU/Linux
wget cpsc335.com/casts.csv
Used to get the casts.csv file from cpsc335.com
rm casts.csv
Used to remove a file.
nmap <hostname or IP address>
Used to scan a single hostname or IP address or range of addresses
man ls
Used to view the manual page for the ls command. -m fill width with a comma separated list of entries
>
Will create a file if one does not exist. If a file does exist, the content will be overwritten.
Tail command
Will show you the last 10 lines of the file.
Linux
an open-source version of the UNIX operating system
chmod
chmod u=rw,g=r,o= casts.csv Used to change the permissions of a file.
.
current directory.
directory (d)
file with a list of files in the directory.
file file1
file1: ASCII text Can be used to examine the file type of a file.
ls -al
linux command for listing the directory contents without ignoring system files that start with "." and listing them in long list format -rw-r--r-- 1 student student 21734 Apr 7 15:22 casts.csv Owner has read and write permissions, Group and world has read permissions. Student is the file owner and the size is 21734 bytes
ls
list directory contents Desktop Downloads Pictures Templates Videos Documents Music Public thinclient_drives
mkdir dirname
make a new directory
chmod octal format
o - g - ao 0 = owner g = group ao = all others
..
parent directory.
pwd
print working directory It gives you the directory that you are currently in. /home/student
rmdir
remove directory
link (l)
shortcut to a file in the file system.
echo Some text
takes a line of text and prints it back out to the command line, also known as standard output (stdout) Output: Some text
Regular file (-)
text, program file, or an image file.