Skip to content

Commands to resolve our problems or to facilitate our IT life :)

Christian Urcuqui edited this page Oct 20, 2020 · 52 revisions

Tools to windows and Linux, commands and other things

Table of Contents

Linux

how to get information about the system

the next command gets the information about the SO

cat /proc/version

it finds a file with its name

find / -name nombre

get the list of the ports used

netstat -lntu

print the memory ram used in our device

free -m

getting information about the memory and CPU

vmstat

and

top

print the list of users of a system

less /etc/passwd

How create your own commands with alias

The idea is to edit the next file when the program that you would like to use, in my case is "pico".

pico ~/.bashrc

you need to add on the final text the alias plus the command that you want to use

finally, execute the next line

. ~/.bashrc

The next command allows us to find the path of a specific file name

find -name "file name"

Configure a IP to out Internet

The idea is to configure the next "interfaces" with the parameters to out internet

sudo pico /etc/network/interfaces 

Next, it restarts the interfaces in the SO

sudo /etc/init.d/networking restart

How do I verify if the interface are reachable

ip neigh show

Erase the information in a file text

truncate logfile --size 0

Generally commands... erase, move and copy files.

cp -a /source/. /dest/ rm -r [folder]/*

Ubuntu

  • Restart your password

The idea is to enter the recovery mode, just only use "shift" before the log screen. When you are there so let's use the next command

mount -n -o remount, rw /

Next, use the next command to restart the password according to the user.

passwd username_here

Windows

How kill a process running in windows

You can use netstat, with that insert the next code in order to list the process sorted by port

netstat -ano | findstr :8080

with the selected process to kill, write the next line

taskkill /PID typeID /F The next command allows us to print the name and SID of a SAM in a windows computer(only in a cmd with root privileges)

wmic useraccount get name,sid

GitHub

How know the list of repository associated to the .git.

git remote -v

Sometimes, it is necessary to save some local changes and update from the master repository in GitHub without to lose the job done, so, it is important first to commit the files that you need to save from the updating process.

git commit [some files]

next, update your local repository from the external changes.

git pull origin master

If you need to change the local email registered, write the next command.

git config --global user.email "you@example.com"

PostGreSQL

list all databases

\list or \l list all tables in the current database dt

connect to a databse

\connect database_name

execute a sql file in the posgrest environment

psql -f thefile.sql targetdatabase

if you want to delete all the tables in the same squema, so write the next code:

DROP SCHEMA public CASCADE;

To create a new schema:

CREATE SCHEMA public;

if you want to know the postgresql version installed in your environment

SELECT version();

see the view form

\d view


Docker

list the docker containers

docker ps

stop one container with its ID

docker stop container_id

get the docker container shell

sudo docker exec -i -t docker-id /bin/bash

erase everything

docker system prune


AWS

the next command allows us to list our buckets

aws s3 ls

Metasploit

This will determine if we're in a VM

run post/windows/gather/checkvm

The next command will check for various exploits which we can run within our session to elevate our privileges

run post/multi/recon/local_exploit_suggester

Clone this wiki locally