✏️
rjnotes
  • Home
  • Books To Read in 2023
  • Mac & Ubuntu Commands - v2
  • DevOps Tasks
  • AWS Commands
  • AWS IAM Policies
  • Autoscaling Automation
  • Shell Commands - Unix
  • RJTools
  • Github
  • VAP
  • virtualenv
  • Alembic Commands
  • Aerospike commands
  • AWS Lambda Commands
  • AWS Glue Commands
  • AWS IAM Policies
  • Azure Commands
  • Cassandra Commands
  • Clickhouse Commands
  • Conda Commands
  • Docker Commands
  • IV Assignments
  • AWS Pricing
  • LangChain Commands
  • Python templates
  • PyLint
  • Pandas Commands
  • CICD
  • GitBook - How to publish
  • HTTPS Fix
  • Video Fix
  • Sublime
  • YT Videos
  • Template
  • GenAI Cards
  • Assignment Validator
  • Auth
  • Decision Maker Persona
  • Session Time
  • New Language Learning
  • Finnish Learning
  • Paste Image Extension
  • Director vs Head vs VP
Powered by GitBook
On this page

Was this helpful?

Mac & Ubuntu Commands - v2

how to kill port / port kill / kill port:
netstat -vanp tcp | grep 3000
sudo lsof -i tcp:5432
kill 8787
or
lsof -t -i:8000
or
kill $(lsof -t -i:1090)
    https://stackoverflow.com/questions/3855127/find-and-kill-process-locking-port-3000-on-mac
# command

how to clear the file?

: > hello.txt

https://askubuntu.com/questions/390167/how-to-clear-text-in-a-file
screen

https://askubuntu.com/questions/302662/reattaching-to-an-existing-screen-session
netstat -tulpn

Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0 127.0.0.1:8000          0.0.0.0:*               LISTEN      1/python
curl with creds

curl -u :password http://
curl -u username http://

curl -u "rajar":"K&dfUHew98dm" http://api.dev.scrapercentral.com/run_schedule/387031
{"user_id":null,"scrape_template_id":null,"scrape_complete":null,"parse_time":null,"creation_time":"2022-11-08T20:51:20.622887","complete_time":null,"status":"NEW","result":null,"scrape_time":null,"job_id":204142,"schedule_id":387031,"parse_template_id":null,"parse_complete":null,"last_query_time":null,"link":null}%


https://stackoverflow.com/questions/25969196/how-to-define-the-basic-http-authentication-using-curl-correctly
sudo apt update

hping3 --version

sudo hping3 -S -p 443 -c 3 google.com

https://lindevs.com/install-hping3-on-ubuntu/
chattr -i


https://linuxize.com/post/chattr-command-in-linux/
Octal permission

How to get the Octal permission in Ubuntu?
stat -c %a /home/ubuntu/armitage/armitage/bin/run.api.sh

https://askubuntu.com/questions/144921/how-to-get-chmod-octal-permissions-of-the-folder-in-the-terminal
stat commend in Ubuntu

https://freelinuxtutorials.com/secure-cron-permissions-and-ownerships-for-ubuntu-linux/
chown all nested folders

chown -R ubuntu:ubuntu env



https://askubuntu.com/questions/693418/use-chown-to-set-the-ownership-of-all-a-folders-subfolders-and-files
lsb_release -dc
Description:	Ubuntu 20.04.5 LTS
Codename:	focal



https://unix.stackexchange.com/questions/140150/crontab-e-sometimes-fails-with-creation-of-temporary-crontab-file-failed
strace crontab -e


strace crontab -e
execve("/usr/bin/crontab", ["crontab", "-e"], 0x7ffe83719c78 /* 30 vars */) = 0
access("/etc/suid-debug", F_OK)         = -1 ENOENT (No such file or directory)
brk(NULL)                               = 0x55aeea452000

quotaoff -a

quotaon
quotaoff

sudo apt install quota

https://askubuntu.com/questions/262758/removing-the-filesystem-quota-on-a-partition

https://manpages.ubuntu.com/manpages/bionic/man8/quotaon.8.html

https://www.digitalocean.com/community/tutorials/how-to-set-filesystem-quotas-on-ubuntu-18-04

https://stackoverflow.com/questions/41441636/cronatab-e-raises-this-error-tmp-crontab-js8bky-no-such-file-or-directory-cr
UFW

https://www.digitalocean.com/community/tutorials/how-to-set-up-a-firewall-with-ufw-on-ubuntu-22-04
How to identify tmp folder is empty?

https://stackoverflow.com/questions/41441636/cronatab-e-raises-this-error-tmp-crontab-js8bky-no-such-file-or-directory-cr
umount /tmp
umount: /tmp: not mounted.
crontab -e and temporary

ls -l /etc/crontab

https://askubuntu.com/questions/866680/why-is-my-ubuntu-crontab-temporary
#LeN

crontab -e

Running crontab -e edits users' crontabs (rather than the system crontab /etc/crontab). If you run sudo crontab -e, this edits the root account's user crontab (which is not the same as /etc/crontab). The root account's user crontab is usable, but is often not what system administrators wish to edit.

https://askubuntu.com/questions/866680/why-is-my-ubuntu-crontab-temporary
T in Timestamp

https://stackoverflow.com/questions/29281935/what-exactly-does-the-t-and-z-mean-in-timestamp

Z in Timestamp

The Z actually stands for Zulu, which is the "name" of UTC0. It sounds weird but every time zone has its respective name.
Z in Timestamp

https://www.timeanddate.com/time/aboututc.html

Zulu time
https://www.timeanddate.com/time/zones/z
UTC history

https://www.timeanddate.com/time/aboututc.html

https://stackoverflow.com/questions/29281935/what-exactly-does-the-t-and-z-mean-in-timestamp
https://support.brave.com/hc/en-us/articles/360020406572-How-do-I-set-Brave-to-be-my-Default-Browser-
Linux command games


https://itsfoss.com/best-command-line-games-linux/
2048 game

https://itsfoss.com/2048-game/
How to add a new browser by command?

ls -l /usr/bin/x-www-browser

sudo update-alternatives \
  --install /usr/bin/x-www-browser x-www-browser /usr/local/bin/waterfox 210

 update-alternatives --config x-www-browser


# How to remove
sudo update-alternatives --remove x-www-browser /usr/local/bin/waterfox

https://unix.stackexchange.com/questions/584478/how-to-add-browser-to-update-alternatives
code . 
vs
cdoe ..

Code . 
	will open up the current folder

Code ..
	will open up the parent folder 
get utc time in ubuntu


timedatectl


https://askubuntu.com/questions/27528/how-can-i-display-the-current-time-date-setting
Set timezone

https://askubuntu.com/questions/558090/ls-to-show-dates-and-times-in-utc
lsb_release -dc
gunzip -r build
scp -r ubuntu@18.221.155.99:/home/ubuntu/rjtest/scrapercentralui/build /Users/str-kwml0020/cprojects/scbuild/.
netcat

https://www.unixmen.com/play-with-netcat-in-ubuntu/
netcat

https://www.unixmen.com/play-with-netcat-in-ubuntu/
telnet

https://www.howtoforge.com/how-to-install-and-use-telnet-on-ubuntu/
tree -d -L 3

will show all folders clearly

.
├── BUILDS
│   └── Latest
├── env
│   ├── bin
│   │   └── __pycache__
│   ├── env -> /home/ubuntu/armitage/env
│   ├── include
│   │   └── site
│   └── lib
│       └── python3.8
└── frontend
    ├── current -> /home/ubuntu/armitage/frontend/releases/Latest
    ├── prev -> /home/ubuntu/armitage/frontend/releases/Latest
    └── releases
        └── Latest

15 directories
Permissions

sudo chmod 777 /media/part1

The permissions (in this case 777) are as follow:

7 - Full (Read, Write & Execute)
6 - read and write
5 - read and execute
4 - read only
3 - write and execute
2 - write only
1 - execute only
0 - none



https://askubuntu.com/questions/158735/how-to-set-permissions-so-that-i-can-read-and-write-to-another-partition
Crontab logs


grep CRON /var/log/syslog

tail -f /var/log/syslog


https://askubuntu.com/questions/56683/where-is-the-cron-crontab-log
stat --format '%A %U %G' /var/spool/cron/crontabs

https://askubuntu.com/questions/296107/all-commands-in-my-crontab-fail-with-permission-denied
dpkg --get-selections | grep --invert-match deinstall | cut --fields 1 | grep pam
chage -l ubuntu

https://www.thegeekdiary.com/crontab-error-you-user-are-not-allowed-to-access-to-crontab-because-of-pam-configuration/
/var/log/syslog

grep CRON /var/log/syslog
	https://askubuntu.com/questions/56683/where-is-the-cron-crontab-log
sudo find . -xdev -type f -size +100M

https://linuxize.com/post/find-large-files-in-linux/
https://stackoverflow.com/questions/2556190/random-number-from-a-range-in-a-bash-script
Htop in Mac

https://www.cyberciti.biz/faq/install-htop-on-macos-unix-desktop-running-macbook-pro/
ls -l --block-size=M

ls -l --block-size=K

ls -l --block-size=B

https://linuxhandbook.com/show-file-size-linux/
awk

https://stackoverflow.com/questions/26006790/file-size-in-bits-with-ls
df -h /


sudo du -hsx /* | sort -rh | head -n 40

sudo du -hsx /home/ubuntu/* | sort -rh | head -n 40

sudo du -hsx /home/ubuntu/etlspace/* | sort -rh | head -n 40

sudo du -hsx * | sort -rh | head -n 40

/home/ubuntu/etlspace


https://askubuntu.com/questions/266825/what-do-i-do-when-my-root-filesystem-is-full
clear /var/cache
du -hx --max-depth=1 /
sudo apt-get clean
https://askubuntu.com/questions/171678/can-i-delete-var-log-files-due-to-low-root-space
https://ubuntuhandbook.org/index.php/2020/12/clear-systemd-journal-logs-ubuntu/

sudo journalctl --rotate

sudo journalctl --vacuum-time=2days

sudo journalctl --vacuum-size=100M

sudo journalctl --vacuum-files=5

sudo journalctl --vacuum-size=2M




sudo journalctl --vacuum-size=2M
Vacuuming done, freed 0B of archived journals from /run/log/journal.
Deleted archived journal /var/log/journal/ec2ad39c750bc054cb154514551bc50b/system@0005f08878ffc27f-ed98f0af79414cfd.journal~ (16.0M).
Deleted archived journal /var/log/journal/ec2ad39c750bc054cb154514551bc50b/user-1000@0005f0d9608458e4-af0c8691aee7b60b.journal~ (8.0M).
Deleted archived journal /var/log/journal/ec2ad39c750bc054cb154514551bc50b/system@0005f0d95e7b172b-73aab0c5aecb63a4.journal~ (8.0M).
Deleted archived journal /var/log/journal/ec2ad39c750bc054cb154514551bc50b/system@8411ff7c27574f67b1a36811db24abfa-0000000000000001-0005f0d95e77a003.journal (8.0M).
Deleted archived journal /var/log/journal/ec2ad39c750bc054cb154514551bc50b/user-1000@5f2d2a7ab8914060a6ced2f50e6d0ac2-000000000000041e-0005f0d960844e7a.journal (8.0M).
Deleted archived journal /var/log/journal/ec2ad39c750bc054cb154514551bc50b/system@8411ff7c27574f67b1a36811db24abfa-00000000000016a4-0005f13935c79ef6.journal (8.0M).
Deleted archived journal /var/log/journal/ec2ad39c750bc054cb154514551bc50b/user-1000@5f2d2a7ab8914060a6ced2f50e6d0ac2-0000000000001c6a-0005f16821618b39.journal (8.0M).
Deleted archived journal /var/log/journal/ec2ad39c750bc054cb154514551bc50b/system@fa0e9889a65a4e03aef158c88a6f854b-0000000000000001-0005f168dea957d3.journal (16.0M).
Deleted archived journal /var/log/journal/ec2ad39c750bc054cb154514551bc50b/user-1000@abe5295348bb472f8c8b46cee85d297c-000000000000500f-0005f1690012c311.journal (8.0M).
Vacuuming done, freed 88.0M of archived journals from /var/log/journal/ec2ad39c750bc054cb154514551bc50b.
Vacuuming done, freed 0B of archived journals from /var/log/journal.
sudo apt remove $(dpkg-query --show 'linux-modules-*' | cut -f1 | grep -v "$(uname -r)")

https://serverfault.com/questions/1098556/how-to-cleanup-usr-lib-modules-and-usr-lib-x86-64-linux-gnu
dpkg-query --show 'linux-modules-*'


dpkg-query --show 'linux-modules-*' | cut -f1


dpkg-query --show 'linux-modules-*'
linux-modules-5.15.0-1026-aws	5.15.0-1026.30
ssh -o StrictHostKeyChecking=no localhost





https://stackoverflow.com/questions/71204445/how-to-skip-fingerprint-checking-when-sudo-ssh-localhost
see how many python process in ubuntu


ps x | grep python

https://askubuntu.com/questions/18828/too-many-python-processes-running
rename all .png to .jpg

mogrify -format png *.jpg 


https://askubuntu.com/questions/457604/bulk-converting-images-from-one-format-to-another
cat /etc/passwd
	root:x:0:0:root:/root:/bin/bash
	daemon:x:1:1:daemon:/usr/sbin:/usr/sbin/nologin
	bin:x:2:2:bin:/bin:/usr/sbin/nologin
	sys:x:3:3:sys:/dev:/usr/sbin/nologin
	sync:x:4:65534:sync:/bin:/bin/sync
	
awk -F: '{ print $1}' /etc/passwd
	root
	daemon
	bin
	sys
	sync
	games
	man
	
awk -F: '{ print $1}' /etc/passwd | grep "ubuntu"
	ubuntu



grep raja.raman /etc/passwd
	raja.raman:x:1001:1001:John Doe:/home/raja.raman:/bin/bash


grep ubuntu /etc/passwd
	ubuntu:x:1000:1000:Ubuntu:/home/ubuntu:/bin/bash

https://www.linuxfordevices.com/tutorials/linux/list-all-users-in-ubuntu
https://unix.stackexchange.com/questions/588102/how-to-remove-quotes-from-text

aws sts get-caller-identity --query Account | tr -d \"
	723675304964
https://www.rosehosting.com/blog/list-all-installed-packages-with-apt-on-ubuntu/


sudo apt list --installed


sudo apt list --installed | less

sudo apt list --installed | grep -i apache

sudo apt list --installed | grep -i apache2-utils | cut -d '.' -f 1

| cut -d '.' -f 1



https://linuxopsys.com/
https://linuxopsys.com/topics/delete-user-home-directory-on-ubuntu
How to store only top 10 lines to text?


sudo apt list --installed > a.txt

this stores everything, but we need only top 10
https://serverfault.com/questions/958003/how-to-disable-warning-apt-does-not-have-a-stable-cli-interface
journalctl -xe

	-e: Jump to the end of the journal logs
	-x: Show extra information on the log entries (if available)


journalctl -p 3 -xb
	-p 3 : filter logs for priority 3 (which is error)
	-x : provides additional information on the log (if available)
	b : since last boot (which is the current session)

	Log Priority
	https://prnt.sc/VqGK3vRey8r_


journalctl -p 4..6 -b0

https://linuxhandbook.com/journalctl-command/
cat /var/awslogs/bin/awslogs-nanny.sh


	#!/bin/sh
	# Version: 1.4.9
	PIDFILE=/var/awslogs/state/awslogs.pid
	LOCKFILE=/var/awslogs/state/awslogs.lock

	# Bail out if PID file doesn't exist. It implies that the
	# process was never started.
	if [ ! -f $PIDFILE ]
	then
	    exit 0
	fi

	/usr/bin/ps -C -p `/usr/bin/cat $PIDFILE` | /usr/bin/grep "/var/awslogs/bin/awslogs-agent-launcher.sh" > /dev/null
	RETVAL=$?
	echo
	[ $RETVAL != 0 ] && [ -f $LOCKFILE ] && /usr/sbin/service awslogs restart
How to remove a package?

sudo apt remove minio


	sudo apt remove minio
	Reading package lists... Done
	Building dependency tree
	Reading state information... Done
	E: Unable to locate package minio
/etc/hosts
/etc/hostname

https://askubuntu.com/questions/811098/when-i-run-a-sudo-command-it-says-unable-to-resolve-host

yxs

PreviousBooks To Read in 2023NextDevOps Tasks

Last updated 1 year ago

Was this helpful?