ls command is used to list files in linux. It is same as dir on windows. ls -la List all files in long format (l), a is to show hidden files ls -b Show only file names ls -1 Show only file names. One file per line […]
Linux User
Lock User Account in Linux usermod […]
Server Load
Here are some useful commands to check server load. iostat shows disk IO usage. %iowait shows how much time process wait for disk operation. This should be 0. If you are on VPS, check for %steal to see if host server is overloaded.
1 |
iostat 1 10 |
Checks for processes in āDā state
1 |
for x in `seq 1 1 30`; do ps -eo state,pid,cmd | grep "^D"; echo "-"; sleep 2; done |
Top processes using CPU […]
mycomputer
These are some software/settings i have on my computer running Ubuntu 20.04 Steam store games on different Disk GNOME Shell Extension Install TeamSpeak Client on Ubuntu Separate Google Hangout icon in Ubuntu 18.04/20.04 […]
bash: man: command not found
When running man command on a debian server, i get error
1 2 3 |
root@lab:~# man sftp -bash: man: command not found root@lab:~# |
This is because man-db package not installed on the server. To fix, install man-db package with
1 |
apt install man-db |
See Errors […]
Show git branch in terminal

When working with git, to avoid accidental commit to wrong branch, it will be better if terminal show the branch name you are currently in. To display “git branch” in terminal, edit .bashrc
1 |
vi ~/.bashrc |
Add following code to end of the file.
1 2 3 4 5 6 7 |
# Show git branch in command promt if git repo show_git_branch() { git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/' } PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\[email protected]\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]$(show_git_branch)\$ ' |
You will need to restart terminal after making changes to ~/.bashrc file […]
Find Reverse-DNS/PTR using dig, nslookup, host
Reverse-DNS/PTR is used by mail servers. It is used to map an IP address to FQDN or hostname. To find Reverse DNS record for an IP address, run
1 |
nslookup IP_ADDR_HERE |
In this example IP 51.38.246.115 have a Reverse DNS record ok.serverok.in Using dig You can also use dig command to find PTR record for an IP […]
Disable SELinux on CentOS/RHEL
To disable SELinux Method 1
1 2 |
sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config setenforce 0 |
Method 2 edit file
1 |
vi /etc/selinux/config |
Find
1 |
SELINUX=enforcing |
Replace with
1 |
SELINUX=disabled |
Reboot the server with
1 |
reboot |
You can disable selinux for current session by running command
1 |
setenforce 0 |
See SELinux […]
Show Hidden Files
For linux to show hidden files when you type ls command Edit ~/.bashrc
1 |
vi /root/.bashrc |
Add line
1 |
alias ls='ls -la --color' |
Save and exit. Now you need to re login to SSH to see the hidden files when you type “ls” After editing the file will look like
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
[root@194 ~]# cat /root/.bashrc # .bashrc # User specific aliases and functions alias rm='rm -i' alias cp='cp -i' alias mv='mv -i' alias ls='ls -la --color' # Source global definitions if [ -f /etc/bashrc ]; then . /etc/bashrc fi [root@194 ~]# |
[…]
curl using cookie
Here is some example of using curl to login to site, use cookie to do further requests.
1 2 |
curl -k --cookie-jar ./cookies_hotfile --data "returnto=%2F&user=USERNAME_HERE&pass=PASSWORD_HERE" http://site.com/login.php curl -L -O --cookie ./cookies_hotfile http://site.com/dl/5222/4444/file.zip.html |
See curl […]