25 Search results

For the term "bash".

Set BASH as Default Shell

Enter at the prompt $ bash If command not found error, install BASH # pkg_add -r -v bash Now find where BASH is installed $ which bash You should see (Ubuntu) /bin/bash Change shell to BASH $ chsh -s /bin/bash username username is your User Name You should see: Password: Provide your login password You’ll need to logout (exit) and…

BASH Shell Notes

The BASH Environment BASH executes in this order /etc/environment /etc/profile /etc/bash.bashrc /home/user/.profile /home/user/.bashrc Interactive vs Non-interactive Shell interactive execution order: /etc/profile then the first readable of ~/.bash_profile, ~/.bash_login, and ~/.profile .profile – is read when an interactive login shell is started. /etc/profile ~/.bash_profile ~/.bash_login ~/.profile non-interactive execution order: /etc/bash.bashrc then ~/.bashrc ~/.bashrc – is read when a non-login interactive shell…

Find and Kill All Processes One Liner

Brilliant – where you need it – like when you accidentally try to open 8000 html files at once with your browser. sudo kill $(ps aux | grep ‘iceweasel’ | awk ‘{print $2}’) credit for Find and Kill All Processes One Liner – bash using grep and awk

Some Bash Scripts to Manage Remote Server

Script to Update and Upgrade #! /bin/bash chmod 700 /usr/bin/apt-get chmod 700 /usr/bin/aptitude chmod 700 /usr/bin/dpkg swapoff -a chown username:username /home/username/* chmod 700 /home/username/* apt-get update && apt-get upgrade –show-upgraded -y Script to End session and Harden some critical files #! /bin/bash swapon -a chmod 000 /usr/bin/apt-get chmod 000 /usr/bin/aptitude chmod 000 /usr/bin/dpkg find /home/username/ -size 0 -exec rm '{}'…

Bash PS1 Manual Prompt Variables

PS1=’\[$(tput bold)$(tput setab 1)$(tput setaf 2)\]\t \u@\h \w \[$(tput sgr0)\] ‘ https://linuxconfig.org/bash-prompt-basics \a : an ASCII bell character (07) \d : the date in “Weekday Month Date” format (e.g., “Tue May 26”) \D{format} : the format is passed to strftime(3) and the result is inserted into the prompt string; an empty format results in a locale-specific time representation. The braces…

Block All Traffic to Your New Remote Server

I block all traffic to a new server while I setup users and environment using Netfilter AKA iptables. Nothing else gets in or out of the box but me. This requires 2 scripts actually. One to close the machine to all other IPs but mine, and one to “unblock”. You need to unblock while installing other software, re. LAMP, when…

Tunnel MySQL Over SSH

Assuming On a “remote.com” server that we will connect to from our LocalMachine 1) MySQL database named “database” 2) MySQL database is running on remote server “remote.com” 3) MySQL is running and listening on (standard) localhost:port “127.0.0.1:3306” 4) MySQL username “mysql_user_name” 5) MySQL password “mysql_password” 6) SSH must be listening on port 9999 7) SSH AllowUsers “ssh_user_name” 8) SSH password…

Systemd ssh Reverse Tunnel on Debian 9 Stretch

I have used rc.local for years to setup an ssh reverse tunnel on boot under Debian up until Stretch. Now like many others I imagine, I’ve had to convert to systemd. I read everything I could about the choice for deprecating rc.local for systemd. I can say that systemd may be powerful, but systemd’s complexity entails a huge learning-curve for…

Joomla Permissions Settings

Permissions Settings are the central problem with all CMS. Here is how I set permissions while installing extensions in Joomla. Before and after installing an extension, I use these BASH scripts to change permissions so that nothing hangs. (it almost always does without using these) Optional security tip: If it is possible in your environment, stopping Apache during the install…

Debian Environment Variables

And then I lived happily ever after – Fixed – BASH scripts executed from a user as sudo, resulted in the root ownership. In other words, a backup script executed by user became the property of root