Home kali command & paste
Post
Cancel

kali command & paste

The id command displays the identity of the user running the session along with the list of groups they belong to

$ id
uid=1000(kali) gid=1000(kali) groups=1000(kali),27(sudo)

The uname -a command returns a single line documenting the kernel name (Linux), the hostname, the kernel release, the kernel version, the machine type (an architecture string such as x86_64), and the name of the operating system (GNU/Linux).

$ uname -a
Linux kali 5.8.0-kali3-amd64 #1 SMP Debian 5.8.14-1kali1 (2020-10-13) x86_64 GNU/Linux

The ps aux command lists the processes currently running and helps to identify them by showing their PID. Once you know the PID of a process, the kill -signal pid command allows you to send it a signal (if you own the process). The jobs command lists the processes running in the background; running fg %job-number (for foreground) restores a job to the foreground. When a command is running in the foreground (either because it was started normally, or brought back to the foreground with fg), the Control+Z key combination pauses the process and resumes control of the command line. The process can then be restarted in the background with bg %job-number (for background).

You can retrieve the kernel logs with the dmesg command. Systemd’s journal also stores multiple logs (stdout/stderr output of services, syslog messages, kernel logs) and makes it easy to query them with journalctl. (ex: journalctl -u ssh.service).

The find directory criteria command searches for files in the hierarchy under directory according to several criteria.

$ find /etc -name hosts
/etc/hosts
/etc/avahi/hosts
$ find /etc -name "hosts*"
/etc/hosts
/etc/hosts.allow
/etc/hosts.deny
/etc/avahi/hosts

lspci lists PCI devices, lsusb lists USB devices, and lspcmcia lists PCMCIA cards (pcmciautils must be installed with apt update followed by apt install pcmciautils).

Job control

kali@kali:~$ ping -i 10 localhost &
[1] 3605
kali@kali:~$ ping -i 10 127.0.0.1 &
[2] 3606
kali@kali:~$ jobs -l
[1]-  3605 Running                 ping -i 10 localhost &
[2]+  3606 Running                 ping -i 10 127.0.0.1 &
kali@kali:~$ kill %1
kali@kali:~$ jobs -l
[1]-  3605 Terminated              ping -i 10 localhost
[2]+  3606 Running                 ping -i 10 127.0.0.1 &
kali@kali:~$ kill %2
kali@kali:~$ jobs -l
[2]+  3606 Terminated              ping -i 10 127.0.0.1
#find out the type of CPU on your Kali host:
kali@kali:~$ sudo dmesg | grep CPU0:
#info regarding the Ethernet adapter:
kali@kali:~$ lspci | grep Ethernet
#info on your Graphics card:
kali@kali:~$ lspci -v -s `lspci | grep VGA | cut -f1 -d\ `
#to find the kernel version:
kali@kali:~$ uname -r
#how much memory is free:
kali@kali:~$ free
#how much disk usage is free on each partition:
kali@kali:~$ df

#start sshd:
kali@kali:~$ sudo systemctl start ssh
#enable sshd at boot:
kali@kali:~$ sudo systemctl enable ssh
#change the default password and generate new SSH host keys:
kali@kali:~$ passwd
kali@kali:~$ sudo rm /etc/ssh/ssh_host_*
kali@kali:~$ sudo dpkg-reconfigure openssh-server
kali@kali:~$ sudo service ssh restart

#start up Apache and Postgres:
kali@kali:~$ sudo systemctl start apache2
kali@kali:~$ sudo systemctl start postgresql
#create a standard user account:
kali@kali:~$ sudo adduser username
kali@kali:~$ sudo passwd username
#add the new user to the sudo group:
kali@kali:~$ sudo usermod -a -G sudo username
#change the default login shell to be bash:
kali@kali:~$ sudo chsh -s /bin/bash username
#stop the Network Manager service and completely disable it at boot time:
kali@kali:~$ sudo systemctl stop NetworkManager.service
kali@kali:~$ sudo systemctl disable NetworkManager.service
#check the status of Network Manager managed interfaces with:
kali@kali:~$ nmcli dev status
#configure your Kali machine for DHCP on eth0, changing the `/etc/network/interfaces` file to include:
auto eth0
iface eth0 inet dhcp
#bring down the eth0 interface:
kali@kali:~$ sudo ifconfig eth0 down
#connect to the wireless network using your wireless USB dongle;
#generate a PSK using the following command:
kali@kali:~$ wpa_passphrase myssid wpa-password
#insert the PSK together with the following into your `/etc/network/interfaces` file:
auto wlan0
iface wlan0 inet dhcp
     wpa-ssid myssid
     wpa-psk {whatever the PSK hash was}
#spin up the interface:
kali@kali:~$ sudo ifup wlan0

Home of the Linux course

This post is licensed under CC BY 4.0 by the author.