CodeHint


Linux (41 items)



ls
List directories
ls -lah = List all files and hidden files
ls -lrt = List files at crescent modified order
ls -F = List files and only directories with slash
ls -i = List inode from each file
  Edit
xargs
Get an output from a command and pass as argument to another command.
ls | xargs rm -rf
  Edit
awk
Prints an output from a command to the screen separated in arguments:
ls | awk '{print $2}'
  Edit
chmod -R 777 target

Changes permission recursively

  Edit
ab -n 1000 -kc 100 target

Simulate requests and simultaneous requests to an specific target

  Edit
top -i 1
Show processes at 1 second interval
us: user cpu time (or) % CPU time spent in user space
sy: system cpu time (or) % CPU time spent in kernel space
ni: user nice cpu time (or) % CPU time spent on low priority processes
id: idle cpu time (or) % CPU time spent idle
wa: io wait cpu time (or) % CPU time spent in wait (on disk)
hi: hardware irq (or) % CPU time spent servicing/handling hardware interrupts
si: software irq (or) % CPU time spent servicing/handling software interrupts
st: steal time - - % CPU time in involuntary wait by virtual cpu while hypervisor is servicing another processor (or) % CPU time stolen from a virtual machine
  Edit
watch -n 1 "netstat -anp | grep :80 | grep ESTABLISHED | wc -l"

Watch numbers of established connections at specific port

  Edit
chown -R user:group target

Changes user and group recursively for an specific target

  Edit
find / -type f -name redis-cli

Search specific type of file starting from specific location

  Edit
halt

Instructs the hardware to stop all CPU functions

  Edit
poweroff

Sends an ACPI signal which instructs the system to power down

  Edit
reboot

Instructs the system to reboot

  Edit
df -kh

Verify disks size and NFS (human readable)

  Edit
cat -n filename

Shows file content with line numbers

  Edit
wc -lwc
wc (word counter)
Show total number of lines from stream. 
Commonly used with pipe operator
wc -l = Number of lines
wc -w = Number of words
wc -c = Number of bytes
  Edit
watch -n 1 "command"

Executes some command repeatedly after -n seconds interval

  Edit
sudo apt-get instal package

Install some package

  Edit
bc
Simple calculator. To quit enter quit.
Remember scale variable
  Edit
alias lista='ls -lahF'

Create an alias for a command or subset of commands

  Edit
unalias alias

Destroy an alias

  Edit
typeset

Returns env variables and functions

  Edit
lscpu

Returns CPU properties

  Edit
free -hm

Returns memory properties

  Edit
date +%d/%m/%Y

Returns date and format it (dont forget the plus sign)

  Edit
/proc/cpuinfo

Shows cpu info

  Edit
ssh-keygen -t rsa

Generate public key. Mostly at ~/.ssh

  Edit
ssh-copy-id myname@host

Saves ssh credentials for future automatic connection

  Edit
openssl pkcs12 .pfx -clcerts -nokeys -out public.crt

Extracts PFX to CRT

  Edit
openssl pkcs12 .pfx -nocerts -nodes -out private.rsa

Extracts PFX to RSA

  Edit
tr replace search

Replace one search pattern to another Ex: tr "\n" " "

  Edit
sort /etc/passwd
Order file lines
-f (Ignore case)
-r (Revert)
  Edit
unzip something.zip -d folder

Extract .zip to a certain folder

  Edit
unrar e unrar.zip ./folder/

Extracts .rar file inside an especif folder

  Edit
netstat -vanp tcp

Show all tcp connections (and ports)

  Edit
find . /! -user root -print

Find all files which owner is different from root

  Edit
lsof -ti tcp:8080 | xargs kill

Kill services at especif port

  Edit
mkdir -p folder1/folder2/folder3

Create folder with parents

  Edit
  Sudoers location

/etc/sudoers

  Edit
iotop

iotop watches I/O usage information output by the Linux kernel (requires 2.6.20 or later) and displays a table of current I/O usage by processes or threads on the system

  Edit
vmstat

vmstat (virtual memory statistics) is a computer system monitoring tool that collects and displays summary information about operating system memory, processes, interrupts, paging and block I/O. Users of vmstat can specify a sampling interval which permits observing system activity in near-real time.

  Edit
export TMOUT=0

Prevent from being kicked by server

  Edit