Skip to content

Instantly share code, notes, and snippets.

View jadia's full-sized avatar
💭
Progress beats Perfect.

Nitish Jadia jadia

💭
Progress beats Perfect.
View GitHub Profile
@jadia
jadia / noOfSSHconnections.md
Created May 30, 2019 06:33
Check number of SSH connection to the server
sudo netstat -tpna | grep 'ESTABLISHED.*sshd'
@jadia
jadia / config_edit_script.md
Created February 7, 2019 11:30
Change entry in a config file

Change an entry in a config file using sed in bash.

sed -r '/PasswordAuthentication/ s/^#/ /; s/(PasswordAuthentication ).*$/\1 no/' ssh_config
        ^ pattern to match        ^remove                             ^ change value
                                  comment
@jadia
jadia / dpkg_daily_update_lock.md
Last active August 18, 2019 09:04
dpkg lock held by daily update ubuntu 18 server
root@acer:/home/stephen# apt install htop
 E: Could not get lock /var/lib/dpkg/lock - open (11: Resource temporarily unavailable)
 E: Unable to lock the administration directory (/var/lib/dpkg/), is another process using it?

disable that headache with:

sudo systemctl disable apt-daily.timer && \
sudo systemctl disable apt-daily-upgrade.timer
@jadia
jadia / git_deleted_files.md
Last active February 1, 2019 05:05
Git commit all deleted files

Git commit all deleted files

git add -u

man from git-add

-u, --update
@jadia
jadia / youtube-dl_playlist_formatted.md
Created January 31, 2019 13:35
youtube-dl playlist download command

Download playlist using youtube-dl in formatted manner

sudo youtube-dl -ic -o '%(playlist_index)s. %(title)s.%(ext)s' https://www.youtube.com/.....
@jadia
jadia / git_pull_hard.md
Created January 26, 2019 15:21
New repository doesn't match with existing local repo

git pull origin master --allow-unrelated-histories

@jadia
jadia / alt_ctrl_ubuntu_workspace.md
Last active January 26, 2019 05:12
Force alt + tab to switch only on current workspace in GNOME shell

Force alt + tab to switch only on current workspace in GNOME shell. Here is the solution I came up with:

Very fast & easy, without any installations/extensions:

  1. Install dconf-editor (already installed on current debian/ubuntu distributions):

    sudo apt-get install dconf-editor
    
  2. Open dconf-editor (from the Dash or a Terminal)

@jadia
jadia / newVMimage.md
Last active October 4, 2019 05:19
Create new qcow2 image for KVM
sudo qemu-img create -f qcow2 ~/VOLUME-NAME.qcow2 30G
                                 ^[name of storage]
@jadia
jadia / yesNoInC.md
Last active January 17, 2019 12:00
Yes/No option in C program

I had the following code and the yes no functionality won't work.

printf("\nDo you wish to add more records? [y/n] ");
		scanf("%c", &choice);
		printf("\nYour choice: %c\n", choice);
		if (choice != 'y')
		{
			printf("Making choice false.");
 addMore = false;
@jadia
jadia / wrong_epel.md
Created December 3, 2018 20:04
How to remove EPEL 7.0 repo from CentOS 6.5

Remove the previous epel release and install the correct one.

yum remove epel-release
wget http://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm
rpm -ihv epel-release-6-8.noarch.rpm