cat /etc/os-release
lsb_release
To Know more about lsb_release click here
man <command>
man touch
man mkdir
man watch
free -m
cat /proc/cpuinfo
uname -a
uname -v
uname -r
ifconfig
ip addr show
ip addr show eth0
df -ah
du -sh /dir/path
netstat
netstat -tunlp
sudo netstat -tulp
# 0.0.0.0:PORT : It means Open port for all
# 127.0.1.1:PORT : local ip, not available outside machine
ps aux | grep nginx
ls /mnt
mount /dev/sd2 /mnt
mount
less /etc/fstab
When a user logs in, environment variables are set from various places. That includes /etc/profile (for all users).
Then all the files in the /etc/profile.d directory.
Then ~/.bash_profile, then ~/.bashrc.
/etc/profile.d/ is a good place to put your application specific setups. For example, I always use SSH for CVS (cf. RSH). So I use:
groups - will show all the attached groups
groups <<userName>> - will show all the attached groups
# user id in hexa
id -u
# Group in haxa
id -g
visudo - and just follow root user
/etc/sudoers.d/<<user>>
and the <<user>> file inside /etc/sudoers.d/<<user>> path has to be update like below
Defaults env_keep += "ftp_proxy http_proxy https_proxy"
Defaults:<<user>> !requiretty
<<user>> ALL=(ALL) NOPASSWD: ALL
chown -R username:groupname file/folder
example - drwxr-xr-x
from the other example
d is for- folder/l is for symboliclink
and it has - owner-rwx, group- rx, other -rx
*chmod table
| Action | Number | Other |
|---|---|---|
| Read | 4 | - |
| Write | 2 | - |
| Execute | 1 | - |
all the process being create in unix can be found on /run directory
the process file extensation is .pid
This tools allow you to intercept http request for debug purpose , To know more https://www.computerhope.com/unix/nc.htm
nc -zvv localhost 27017 - ping from command linenc -l 8080 - will listen on port 8080
| du -h | sort -h - will show the size of all the folder is sorting (more size folder will be on below) |
| du -ks /var/lib/docker/* | sort -nr | head - will show the details of the size of traget folder |
start script
-------------
export JAVA_HOME=/home/ubuntu/software/jdk1.8.0_101;
export JENKINS_HOME=/home/ubuntu/workspace/jenkins_home;
nohup $JAVA_HOME/bin/java -jar /home/ubuntu/software/jenkins.war --httpPort=8081 & echo $! > jenkins_pid.txt
stop script
-------------
kill -9 $(cat jenkins_pid.txt);
rm -rf nohup.out;
rm -rf jenkins_pid.txt;
chown robert file.txt - change the user for file file.txt
groups username - create a user group
chgrp webdev file.txt - change the group name of the file.tx
chown -R user:group folderName/ - this will change the owner of the target folder
tar -xzvf <<file_folder_name>>.tgz - untar the target folder
tar -zcvf <<target_folder>>.tgz <<source_folder>>
options
-z : Compress archive using gzip program
-c: Create archive
-v: Verbose i.e display progress while creating archive
-f: Archive File name
tar xf location/filename.tgz -C path/where/to/extract --strip-components=1
for more help - https://www.cyberciti.biz/faq/how-do-i-compress-a-whole-linux-or-unix-directory/
example: exit 1 or exit 0
Exit code 0 Success
Exit code 1 General errors, Miscellaneous errors, such as "divide by zero" and other impermissible operations
Exit code 2 Misuse of shell builtins (according to Bash documentation) Example: empty_function() {}
mount -o remount,size=2G,noatime /tmp
nc -zvv localhost 8081
uname -a
and
cat /etc/os-release
nslookup <<hostname>>
netstat -tunlp
lsof -i
ssh-keygen
cd /folder/to/generate/ssh-key-pair
ssh-keygen -f id_rsa
ssh-keygen -y -f id_rsa > api2.pub
ssh-keygen -l -f id_rsa
ssh-keygen -l -f id_rsa -f api2.pub
ssh-keygen -t rsa -b 4096 -m PEM -f jwtRS256.key
# Don't add passphrase
openssl rsa -in jwtRS256.key -pubout -outform PEM -out jwtRS256.key.pub
cat jwtRS256.key
cat jwtRS256.key.pub
ssh -i .ssh/id_rsa -L LOCAL_EXPOSED_PORT:TARGET_MACHINE_IP:TARGET_APPLICATION_PORT username@jumphost.host.-name
To see all the cron job use
crontab -l
sudo lsof -i -P -n | grep LISTEN
#if you want to kill a port
sudo kill -9 <port>
watch -n 5 <command> - run the This command will list all the tcp and udp port with pid and other stuff. after that you can use kill commaond kill -9 <pid>
netstat -vanp tcp | grep 8080 # for mac
netstat -tunlp # for unix/linux