Skip to content

List of my frequent Linux terminal commands (updating every week) 📖

Notifications You must be signed in to change notification settings

ManiFast/Small-directory-of-Linux

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 

Repository files navigation

Tools and settings

List of my frequent Lin ux terminl commands (updating every two days)

Its like a bible lmao)
I think in near future I write a small book for Linux like "A bit about Linux in many ways !"


Hint
-=> More about pentesting and tools <=-

Click 🔙 to get back.

Table of Contents:


Main

Commands

Command Description

!$    last argument (напр mkdir ss/sdf)
!!    previous comand
Super+Space change language keyboard
ls show files and folders
  ls -l -a    -l beauty -a all files
  ls -F    -F show folders and files with "/"
touch    create file
cd    previous path
cat    output file
vim    change file
htop    about system
ps    what running

mkdir (-p)    create dir, p-if that dir isnt found, create !
rmdir    remove dir
rm -R    remove not empty dir

mv    rename or move
wc    word count
  wc file.txt -l/w    show lines or words in file
  grep "[A-Za-z]*stas" -E ./*    example, find ...s/Stas in this folder sort    sort to symbols without change
  sort -n    sort by names

cut -d ">" -f 3 file.txt    divorse each column on end ">" and output only third lines in file.txt
  cut -d ">" -f 3 countries.txt | sort -n    example of sorting

find    find file
find /home -name "file*.txt"

grep <-i> <word> <file/path>    find in folders or files, 'i' = ignore case count Aa
  grep -E "@[A-Za-z]*.com" file.txt    find certain fraze in file
  grep "[A-Za-z0-9]*@gmail.com" emails.txt    example, find all email in end @gmail.com
[A-Z] [a-z] [0-9] @ _ - .

curl <URL> parsing for sites, give text from URL
curl https://www.kali.org/ showing html code
curl -s https://hackware.ru/ show code without statistic
curl -A <URL> site didnt know that u use console app with curl
curl --compressed https://www.kali.org/ without binary trash
curl -s https://hackware.ru/ | grep "extra" good sample

If you also have trash, try change charset:
For ex. when u put this: curl http://z-oleg.com/
You see this: 84
And u should look what charset set in HTML in tag

Use iconv: curl http://z-oleg.com/ | iconv -f windows-1251 -t UTF-8 right charset translate

ln    links (like shortcut)
  ln -s /home/Desktop/Dir    link to folder
  ln /home/Desktop/file.txt    create duplicate of file

date    show date (with args)
  date +"%H:%M"    11:32, certain cut date

whoami what user
id which groups u consist
  id root show id root

last who enter in pc
who who now use pc
w what all users do

su change user

fiind find but not use, search for files in a directory hierarchy
whereis locate main place, locate the binary, source, and manual page files for a command
which locate a command
locate <app>/plocate <app> where is program locate, find files by name, quickly

fakeroot fake root in kali

sudo apt search search packages for install

> >>    clear and rewrite/just write at the end
2>    catch errors
  grep cats animals/* 2> errors.txt    find strings with word 'cats' in all files in folder 'animals' and errors write in 'errors.txt' file
  grep aqua colors/* > good.txt 2> nogood.txt    write noerrors msg in 'good.txt' and errors msg in nogood.txt
  /dev/null    always empty folder, like 'black hole')
  2>>    add errors in file, like '>>'
&>    catch errors and noerrors messages (because if you write '>' saving only noerrors messages)

bg    show background process
fg    return to background

top task manager
htop  new task manager

ps list of procces
  ps -aux    show all in all
  ps -ax   ps -aux | grep manifast    find strings with this word

kill <signal>  kill process, find signal from 'ps -aux'
  kill -9 2763
  kill -KILL 2763
  kill -9/KILL %  kill last process
  kill %2  point to second task

<command> &  & - needed for start task into background
  updatedb &

jobs  show tasks list in background

hostname ur nick
hostnamectl show vresion (check the Kernel version and CPU architecture)
lsb_release -a check the release version, description, and operating system codename
uname -a shows the current kernel and OS information
sudo adduser id -un libvirt add user for qemu

ping using for test connection and avalible of server
  ping -c yandex.ru test only 3 times and get right info

sudo date -s "$(wget --method=HEAD -qSO- --max-redirect=0 google.com 2>&1 | sed -n 's/^ *Date: *//p')" set date

install packages in Debian:
sudo dpkg -i <path>
sudo dpkg -i quickhash_3.3.1-1_amd64.deb

Check for supporting vm:
LC_ALL=C lscpu | grep Virtualization

Time:
sudo ln -sf /usr/share/zoneinfo/Asia/Tashkent /etc/localtime

LAN

wifi

nmcli d wifi connect <name> password <password> ifname wlan0 connect wifi

nmtui

nmtui Network Manager TUI

image

Config_of_interfaces

/etc/network/interfaces

image

text:
auto eth0
iface eth0 inet static
address 192.168.0.226/24
gateway 192.168.0.1

Set to default if u have problems with connetion like (ping, browser etc.)

In /etc/network/interfaces u must make like this:

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

source /etc/network/interfaces.d/*

# The loopback network interface
auto lo
iface lo inet loopback

auto eth0
#iface eth0 inet static
#address 193.168.0.224/24
#gateway 192.168.0.1
iface eth0 inet dhcp

Others

systemctl restart NetworkManager.service restart connections

Keybinds

In the Terminal:

Move:
стрелки moving cursor
Shift + стрелки list terminal
Shift + PageUp/PageDown list with spacees
Ctrl + PageUp/PageDown switch bookmarks
Ctrl + Shift + PageUp/PageDown moving bookmarks

Close:
Ctrl + D end of file input

Ctrl + C close (kill), OC send signal 'SIGINT'
Ctrl + / close too, OC send signal 'SIGQUIT'
Ctrl + Z sleep
Ctrl + S pause output
Ctrl + Q resume output

Logs

/var/log logs
sudo dmesg log of Linux core
/etc/passwd system accaunts
/etc/shadow all shifered passwords
/etc/group all users groups (f.e how can use sudo)

Input_text_in_file

  1. cat > file.txt << ENDL
    '>' its write in end ENDL its special word witch means end of line (random word)
  2. printf "text" > file.txt

Users

useradd -m add user (with home directory)
userdel -r delete user (with home)

/etc/skel templete of home directory
passwd change password for user

groupadd create group in /etc/group
groupdel delete group

usermod -aG add user to group
deluser delete user from group

Archiving

tar using without "-" tar cvf <name.tar> <folder> create archive (c - create, v - view, f - must be in end)
tar cvf data.tar dataBig/
tar xvf <name.tar> extract archive (x - unzip)
tar xvf data.tar
tar -C <path> -xvf <file> extract to considered folder (C - path)
tar -C home/ -xvf data.tar
tar tf <name.tar> view what in tar (t - test)

Compression

Compressing one file, (for example compress one big tar)

  1. gzip .gz
    gzip <tar file/or 1 big file> zip
    gzip myData.tar
    gunzip unzip

  2. bzip2 .bz2 - best
    bzip2 <file> zip
    bzip2 myData.tar
    bunzip2 <file> unzip

  3. xz .xz
    xz <file> zip
    xz myData.tar
    unxz <file> unzip

  4. zip zip -r <file.zip> <folder> zip folder (r - recorsvely) with beauti adding zip -r data.zip bigData/ unzip <file.zip> unzip unzip data.zip

All in 1 command:
tar - can make compression too

Archiving and compression:
tar cvzf <file.gz> <folder> to .gz (z - create gzip)
tar cvjf <file.bz2> <folder> to .bz2 (j - create bzip2)
tar cvJf <file.xz> <folder> to .xz (J - create xz)

Uncompression archving tar:
tar xvf <file.bz/.bz2/xz> Uncompression archving .bz
tar xvf myData.bz2

Compiling

gcc file.c -o file compiling output for C file
g++ file.c -o file compiling uutput for C++ file

make file gcc file.c -o file
./file run file


gcc

Hot to compile and run c/c++ file. In default gcc can be installed on your system if not ->

sudo apt-get install build-essential manpages-dev
``

Create file, edit it and save like .c or .cpp

For c:
cc program.c -o program

For c++
gcc program.c -o program

or universal:
make program.c

How to run:
./program or /home/Desktop/program

(not necessary)

Generate symbolic information for gdb and warning messages
c:
cc -g -Wall input.c -o executable
c++:
g++ -g -Wall input.C -o executable

Compile a C program that uses math functions
c:
cc myth1.c -o executable -lm

Compile a C++ program that uses Xlib graphics functions
c++:
g++ fireworks.C -o executable -lX11

Compile a program with multiple source files
c:
cc light.c sky.c fireworks.c -o executable
c++:
g++ ac.C bc.C file3.C -o my-program-name

Bash_scripting

var="string" create valuable
read like "cin»var", write in value
var=$1/2 AKA Argument, ./file $1
daytoday=$(date +"%D") example of pasting output command


Keys

^ Its Ctrl
^A ^E go to start or end
^R finding commands
^U clear what written on left
^M new line

^Shift+V paste text
^Shift+Insert paste text too :D

^h show hidden files



Software

VIM

^: open vim command line
! extra ... !q extra quit
w save
q quit
:%s/WORD/REPLEACEWORD/g find and replace (g - all)

ESC NORMAL mode
i INSERT mode
v VISUAL mode

h j k l left down up right
a INSERT after 1 letter
A INSERT in end of line

o new line in down and INSERT
O new line in up and INSERT

gg go to start of file
G go to end of file

w go to 10 word ahead

/ find word (down from cursor)</br ? find word (up from cursor)

in VISUAL mode:
y copy text
x cut text
p paste text

d delete

dd delete line
5dd - delete 5 lines
dw delete word

u like ^Z (back)

cw delete all to right in word (change word)
C delete all to right

Macros

q start to listen what you do
q stop listen
@ do macros
  10@mac - do ten times

Config

My cfg here

sudo vim ~/.vimrc
sudo vim .config/nvim/init.vim

Neo_vim

sudo apt install neovim -y install
sh -c 'curl -fLo "${XDG_DATA_HOME:-$HOME/.local/share}"/nvim/site/autoload/plug.vim --create-dirs \ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim' write this in directory ~/.config/nvim
nvim start

Create config folder: cd ~/.config/
mkdir nvim
nvim nvim/init.vim config
and paste config here

sudo apt install git
:PlugInstall write this in nvim command cmd

https://vimawesome.com/ set plugins here

photo_2022-08-22_10-23-10

Screenshot 2022-08-22 102500

Setting nvim:
in options.txt file

:h <what find> find in all setting in nvim
  :h 'guicursor'> or u can type :h guic<tab>
:set <parametr>=<value>
  :set guicursor=

tldr

tldr is a small tool that provides concise, easy-to-read summaries of information from man guides.

The Debian man command does not have the same format as Archcraft Linux.
On Debian, the man command displays man manuals in text format.
In Archcraft Linux, the man command displays man pages in HTML format.
To get the same look as in Archcraft Linux, you can use the tldr program.
The tldr program provides concise, easy-to-read summaries of information
from man manuals in HTML format. To install the tldr program, you can run the
following command in a terminal:

sudo apt install tldr

It very useful for people like me because show many of examples with all arguments and options like this.
For example you forget something in nmap or dirb programm and it easly show you all examples,
ether you waste time of searching in browser.

image

Linux

Distributions

Debian

apt is a packet manager in Debian

func:
apt install
apt remove
apt search

sudo apt update -y $$ sudo apt upgrade -y full update Linux
  -y without ask

packeges:
sudo apt install ./deb_file install .deb files

Install & Execute BIN files:

chmod + x <filename>
./<filename>

Arch

Pacman is a packet manager in Arch

Funcions:
sudo pacman -S <name of packet> install
sudo pacman -Ss <name of packet> search
sudo pacman -R <name of packet> remove
sudo pacman -R <name of packet> remove expact config (dependencies)
sudo pacman -Rns <name of packet> remove with all config dependencies

sudo pacman -Syu update Linux

Root

sudo su
sudo -i

Permisson

1
sudo chown <file/folder>

2 (for all users)
sudo su
chown -v <file/folder>

3 (most use). from -rwxrwxrwx to -rw-rw-r—, make your script executable
sudo chmod +x


Shared_folder

make a double connection
create directory(folder) (auto amount, permanent)

turn on CD Tools: if it didnt open automaticly, go to
cd /media/user/VBox_GAs_6.1.34/VBox_GAs_6.1.34/
./autorun.sh
sudo apt update
sudo apt install update

in terminal:
sudo usermod -a -G vboxsf <user name> create rights
sudo apt-get install gcc make perl dnt know but must paste


Update

Linux version:
uname -r
6.1.0-kali9-amd64

cat /proc/version
Linux version 6.1.0-kali9-amd64 (devel@kali.org) (gcc-12 (Debian 12.2.0-14) 12.2.0,
GNU ld (GNU Binutils for Debian) 2.40) #1 SMP PREEMPT_DYNAMIC Debian 6.1.27-1kali1 (2023-05-12)

lsb_release -r

Update Debian/Kali:
sudo apt update && sudo apt full-upgrade -y && sudo reboot -f

/etc/apt/sources.list

deb http://http.kali.org/kali kali-rolling main non-free contrib deb-src http://http.kali.org/kali kali-rolling main non-free contrib

apt-get update address update, update software source data.
apt-get upgrade software update, update all installed software.
apt-get dist-upgrade system update, replace the system version.
apt-get clean Clean up garbage, delete all downloaded packages.


ssh

ssh-keygen -t ed25519 -C "your_email@.com"

linux_desktop_environments

Screenshot 2022-08-21 144330

sudo tasksel select startup enviroments
image-104-768x579

KDE

sudo apt install kali-defaults kali-root-login desktop-base kde-plasma-desktop

photo_2022-08-22_16-29-22

xfce

config_bash

bashrc

Paths:
/etc/bash.bashrc
/root/.bashrc

zshrc

Path:
/.zshrc

-> Config.txt <-

grub

GRUB (GNU GRUB - GRand Unified Bootloader) is default OS bootloader wich have quite good configuration.

sudo nvim /etc/default/grub config of GRUB

If you write changes you must reload GRUB

sudo update-grub

Features_of_linux

apt-remove

Delete unuseful dependencies(зависимостей):
sudo apt autoremove

Emoji

image
sed -i 's/prompt_symbol=㉿/prompt_symbol=💻/' ~/.zshrc for user
sed -i 's/prompt_symbol=㉿/prompt_symbol=💀/' ~/.zshrc for root

Terminal

Kali Linux use the Qterminal like main terminal emulator and more like byouye and xfce4-terminal

Tricks

if you press tab in the name that was, it will add itself
ls -l && echo "Stas" if one fails, the next too
ls -l; echo "Stas" add many commands
truncate -s 0 file clear file
| column -t convenient to display in columns (удобно вывести по колонкам)
sudo rm -R / Kill Linux
fakeroot fakeroot

Ctrl + Alt + стрелки switch desktop
Ctrl + h replacement (замена) backspace
Alt + WhellUp/Down loop
U can install only needed programs from different system like:
sudo apt install gnome-calculator or
sudo apt install xfce4-terminal


Do u like it ? Star repo and share it with your friends!)