Posts

Showing posts with the label linux

Useful aliases

alias ll="ls -lah" alias branch="git branch" alias checkout="git checkout" add() { # Colors GREEN="\033[32m" RED="\033[31m" YELLOW="\033[33m" BLUE="\033[34m" RESET="\033[0m" # Arrays for summary added_files=() skipped_files=() # Get changed files (including renamed, deleted, etc.) mapfile -t files commit() { echo "Enter commit message (Ctrl+D to finish):" msg=$(cat) git commit -m "$msg" } git_push() { # Colors RED="\033[0;31m" GREEN="\033[0;32m" CYAN="\033[0;36m" YELLOW="\033[1;33m" NC="\033[0m" CURRENT_BRANCH="$(git rev-parse --abbrev-ref HEAD)" git fetch origin "$CURRENT_BRANCH" >/dev/null 2>&1 echo -e "${CYAN}Commits to push on $CURRENT_BRANCH:${NC}" git log origin/$CURRENT_BRANCH..$CURRENT_BRANCH --oneline || echo "No upstream ...

Disable GRUB timeout

 Add “GRUB_RECORDFAIL_TIMEOUT=0” in /etc/default/grub Then update GRUB by running sudo update-grub Credit: https://techz.io/disable-grub-boot-menu

Speed up shutdown in Linux by reducing default stop timeout

Edit /etc/systemd/system.conf Uncomment and change the value at line DefaultTimeoutStopSec=90s Reboot for the change to take effect (it will not take effect yet after editing the file before reboot).

Telegram icon in dark theme

sudo cp /usr/share/icons/breeze-dark/status/22/telegram* /usr/share/icons/breeze/status/22/ sudo cp /usr/share/icons/breeze-dark/status/24/telegram* /usr/share/icons/breeze/status/24/   Credit: https://github.com/telegramdesktop/tdesktop/issues/7399

Mount windows share on ubuntu

Install the CIFS Utils pkg sudo apt-get install cifs-utils Create a mount point sudo mkdir /mnt/local_share Mount the volume sudo mount -t cifs -o user=<user on Windows> //<windows_ip_address>/<share_folder> /mnt/<local_share> You will be prompted for password   To mount at boot, add to /etc/fstab file: //<windows_ip_address>/<share_folder>cifs user=<user on Windows>,pass=<user passwd> 0 0  

Run MongoDB query form terminal

 mongo localhost:27017/db_name script_name.js > result

Add permanent alias

 Add at the end of file ~/.bashrc alias alias_command 'real command' To load newly created alias immediately: source ~/.bashrc

Move MongDB database

find mongodb config file sudo find / -name mongod.conf -print get dbPath from that file stop mongodb service mongod stop check mongodb is not running sudo systemctl status mongod copy all files from dbPath to new dbPath cp -r old_dbPath new_dbPath chown of new dbPath sudo chown -R mongodb:mongodb new_dbPath change dbPath in mongodb config file to new_dbPath start mongodb sudo systemctl start mongod

Show popup window

 https://wiki.gnome.org/Projects/Zenity

Dropbox not syncing

  sudo chattr -R -i "$HOME/Dropbox" sudo chown -R "$USER" "$HOME/Dropbox" chmod -R u+rw ~/Dropbox dropbox stop; rm -rf ~/Dropbox ~/.dropbox ~/.dropbox-dist; dropbox start -i   Note that Dropbox folder path point to default position. If you have changed this path, make appropriate corrections above

How to become root

sudo su

Mount HDD temporarily on Linux

sudo fdisk -l    mkdir /mnt/mount_name   sudo mount /dev/partition /mnt/mnt_name

Test speaker on Linux

speaker-test -t wav -c 6

Shortcut for app on PlayOnLinux

playonlinux --run appName

Force removal of broken package

sudo dpkg --remove --force-remove-reinstreq package_name

Enable double click to open item in KDE

System Settings, Workspace, Workspace Behavior, General Behavior, Click behavior

Delete all email from mail command

? delete * ? q

Stop Ubuntu from asking password

Run sudo visudo For certain command: username ALL = NOPASSWD: command 1 username ALL = NOPASSWD: command 1, command 2, command 3 Example hensem ALL = NOPASSWD: /bin/systemctl restart httpd.service, /bin/kill For everything: username ALL=(ALL) NOPASSWD:ALL For root: Find the line that says %admin ALL=(ALL) ALL and change it to %admin ALL=(ALL) NOPASSWD: ALL

Running GUI app in Cron

In ~/.profile add these 2 lines: xhost +local: xhost Add env DISPLAY=:0 before cron command 00 06 * * * env DISPLAY=:0 gui_appname To run cron as root or anacron, add this to ~/.bashrc xhost local:mpromber > /dev/null

Check free disk space in Linux

df -h df -h /path/to/dir