Linux Walk Around

The Linux Filesystem

  • /bin - basic programs (Is, cd, cat, etc.)

  • /sbin- system programs (fdisk, mkfs, sysctl, etc)

  • /etc - configuration flies

  • /tmp- temporary files (typically deleted on boot)

  • /usr/bin - applications (apt, neat, nmap, etc.)

  • /usr/share- application support and data files

Basic Linux Commands

Man Pages

A special program called man is used to view these pages. Man pages generally have a name, a synopsis, a description of the command's purpose, and the corresponding options, parameters, or switches.

kali@kali:~$ man ls

Man pages contain not only information about user commands, but also documentation regarding system administration commands, programming interfaces, and more. The content of the manual is divided into sections that are numbered as follows:

1 User Commands

2 Programming interfaces for kernel system calls

3 Programming interfaces to the C library

4 Special files such as device nodes and drivers

5 File formats

6 Games and amusements such as screen-savers

7 Miscellaneous

8 System administration commands

#if we use the -k option with man, we can perform a keyword search as shown below:
kali@kali:~$ man -k passwd

#We can further narrow the search with the help of a regular expression
kali@kali:~$ man -k  '^passwd$'

#We can now look at the exact passwd manual page we are interested in by referencing the appropriate section:
kali@kali:~$ mans passwd

Apropos

With the apropos38 command, we can search the list of man page descriptions for a possible match based on a keyword. Although this is a bit crude, it's often helpful for finding a particular command based on the description. Let's take a look at an example. Suppose that we want to partition a hard drive but can't remember the name of the command. We can figure this out with an apropos search for "partition•.

kali@kali:~$ apropos partition

Mkdir

kali@kali:~$ mkdir notes
kali@kali:~$ cd notes/
kali@kali:~/notes$ mkdir module one
kali@kali:~/notes$ l s
module one
kali@ka1i:~/notes$ rm -rf module/ one/
kali@kali:~/notes$ mkdir "module one"
kali@kali:~/notes$ cd module\ one/
kali@ka1i:~/notes/module one$

kali@kali:~$ mkdir -p test/{ recon, exploit,report}
kali@kali:~$ ls -1 test/
exploit
recon
report

Which

The which command searches through the directories that are defined in the $PA TH environment variable for a given file name. This variable contains a listing of directories that Kali searches when a command is issued without its path. If a match is found, which returns the full path to the file as shown below:

kali @kali :~$ echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
kali@kali:~$ which sbd
/usr/bin/sbd

Locate

The locate command is the quickest way to find the locations of files and directories in Kali. In order to provide a much shorter search time, 'locate searches a built-in database named locate.db rather than the entire hard disk itself. This database is automatically updated on a regular basis by the cron scheduler. To manually update the locate.db database, you can use the updatedb command.

kali @kali :-$ sudo updatedb
kali@kali:-$ locate sbd.exe
/usr/share/windows-resources/sbd/sbd.exe

Find

The find command41 is the most complex and flexible search tool among the three. Mastering its syntax can sometimes be tricky, but its capabilities go beyond a normal file search. The most basic usage of the find command is shown in Listing 14, where we perform a recursive search starting from the root file system directory and look for any file that starts with the letters "sbd".

kali@kali:-$ sudo find / -name sbd*
/usr/bin/sbd
/usr/share/doc/sbd
/usr/sha re/windows-resources/sbd
/usr/share/windows-resources/sbd/sbd.exe
/usr/share/windows-resources/sbd/sbdbg.exe
/var/cache/apt/archives/sbd_l.37-lkali3_amd64.deb
/var/lib/dpkg/ i nfo/sbd .mdSsums
/var/lib/dpkg/info/sbd. list

Managing Kali Linux Services

SSH Service

kali@kali:-$ sudo systemctl start ssh

OR

kali@kali:-$ sudo systemctl enable ssh

#To Check
kali@kali:-$ sudo ss -antlp I grep sshd
LISTEN 0 128 •:22 •:• users:(("sshd",pi d=l343,fd=3))
LISTEN 0 128 :::22 :::* users:(("sshd",pi d=l343,fd=4))

HTTP

kali@kali:~S sudo systemctl start apache2

OR

ka1i @kali: ~$ sudo systemctl enable apache2


#To Check
kali@kali:~~ sudo ss -antlp I grep apache

systemctl

kali@kali:~ systemctl list-unit-files

APT

kali@kali:~$ sudo apt update

kali@kali:-$ apt-cache search pure-ftpd

kali@kali:~$ apt show resource-agents

kali@kali:~$ sudo apt install pure-ftpd

kali@kali:~$ sudo apt remove --purge pure-ftpd

dpkg

kali@kali:-$ sudo dpkg -i man-db_2.1.e.2-s_amd64.deb

Last updated