How to add an existing user to an existing group in Linux? We can use usermod to change/add user group for users. # usermod -a -G group_name user_name -a, –append Add the user to the supplementary group(s). Use only with the -G option. -G, –groups GROUP1[,GROUP2,…[,GROUPN]]] A list of supplementary groups which the user is
Read more
Tag: Linux
Statically linking C and C++ programs
Posted onHow to statically compile C and C++ projects? The compiled executable should lead no dynamical library during execution. I use gcc/g++ to compile the projects. Check this post: Statically Linking C and C++ Programs on Linux with gcc.
How to activate or deactivate a Linux host with Gnome remotely?
Posted onI have a Fedora Linux server with Gnome 3. I want to lock / unlock the remote Gnome desktop remotely. How to activate or deactivate it remotely through SSH? Use gnome-screensaver-command. It is not specific to Gnome 3. Turn the screensaver on (blank the screen): $ gnome-screensaver-command -a If the screensaver is active then deactivate
Read more
How to change the audio track for .mkv files in mplayer?
Posted onHow to change the audio track for .mkv files in mplayer? Key shortcut: # (dvd, mpeg, matroska, avi and libavformat only) cycle through the available audio tracks. tab (mpeg-ts and libavformat only) More: https://www.systutorials.com/b/linux/663/mostly-used-mplayer-keyboard-control/
Chrome reports “Adobe Flash Player was blocked because it is out of date.”
Posted onOn Linux (Fedora 17 x86-64), Chrome keeps reporting “Adobe Flash Player was blocked because it is out of date.” every time I browse a page that contains Flash. How to fix this? I did this and it turned to be working for me: Disable the libpepflashplayer in Chrome by run chrome://plugins/ in the URL bar.
Read more
How to set up proxy over SSH on Windows?
Posted onThis tutorial teaches how to set up SSH proxy on Linux. How to set up one proxy over SSH on Windows? A tutorial of using SSH tunnel as the proxy on Windows is introduced here: https://www.systutorials.com/tutorial/4696/software/proxy-using-ssh-tunnel-on-windows/
Auto completion in Vim
Posted onHow to enable auto code completion in Vim, like in the IDE? Several plugins I use: snipMate: Plugin for using TextMate-style snippets in Vim omnicppcomplete: Plugin for C/C++ omnicompletion neocomplcache: Ultimate auto completion system for Vim
How to manage plugins for Vim?
Posted onThe Vim plugin directory under ~/.vim seems messy—a plugin has different files in different directories and the files from different plugins are put together. This is hard to add/remove plugins. Is there any better method for managing them? I use pathogen and am very happy with it. After installing pathogen, any plugins you want to
Read more
3 Ways of Making Case Insensitive Search in Vim/Vi
Posted onBy default, Vim/Vi’s search is case sensitive. However, if I want to search case insensitively, is there any method? For example, I search for dog, instead of matching dog only case sensitively, I also want to find out phases containing Dog, DOg, etc. There are several methods: 1. Setting the search to be case insensitive
Read more
Make changes to sysctl.conf take effect without rebooting Linux?
Posted onI made some changes to /etc/sysctl.conf. I know it will take effect next time Linux boots. However, how to make the changes to sysctl.conf take effect without rebooting Linux? You can force Linux to reload the new configuration in /etc/sysctl.conf by: execute the following command as root: sysctl -p For more details, check the manual
Read more
How to quickly find out failed disks’ SATA port in Linux? (how to map Linux disk names to SATA ports)
Posted onI find one disk failed on my server which have several ones installed. I know the disk’s name in Linux (e.g. sda, sdb). However, the Linux disk name to SATA port mapping does not follow the same order. Now, I want to find out the failed disks. How to quickly find out them and which
Read more
Git: setting a local branch’s upstream tracking branch
Posted onHow to set a local branch’s upstream tracking branch in git? For example, I want to track remote repository ‘origin’ ‘s branch ‘demo’ with the local ‘demo’ branch. You can set tracking information for the current branch (say cur_branch) of upstream branch (say also cur_branch) in remote repository origin with: git branch –set-upstream cur_branch origin/cur_branch
How to make a swap partition
Posted onHow to make a swap partition on Linux? First, make a new partition (or reuse an existing one if you like). I suggest using cfdisk to create it: https://www.systutorials.com/docs/linux/man/8-cfdisk/ Then, turn the new partition (say, /dev/sdc1) to a swap # mkswap /dev/sdc1 Lastly, turn it on # swapon /dev/sdc1 You can check whether its status
Read more
Setting Swap Priority in Linux
Posted onHow to set swap priority in Linux? Can I use 2 swap partition at the same time? You can set the priority of swap in Linux by swapon. For example, to set /dev/sdc1‘s priority to 0: # swapoff /dev/sdc1; swapon -p 0 /dev/sdc1 You can also put one entry into the /etc/fstab to make it
Read more
How to disable all swaps on Linux
Posted onHow to disable all swaps on Linux to force the application/kernel use the physical memory? To diable all swaps on Linux, run this command as root: # swapoff -a -a means all swaps. Similarly, to enable all swaps on Linux: # swapon -a
x86-64 calling convention by gcc
Posted onWhat is the x86-64 calling convention by gcc? The calling convention of the System V AMD64 ABI is followed on GNU/Linux. The registers RDI, RSI, RDX, RCX, R8, and R9 are used for integer and memory address arguments and XMM0, XMM1, XMM2, XMM3, XMM4, XMM5, XMM6 and XMM7 are used for floating point arguments. For
Read more
Gnome: disabling / deleting keyrings
Posted onHow to disable/delete the current keyrings on gnome? If the Gnome keyrings are not needed, or we forget the password, we can disable/delete the current keyrings. The keyrings are stored under ~/.gnome2/keyrings/ To disabled or delete current keyrings, we can simply delete this folder: rm -rf ~/.gnome2/keyrings/ Remember to backup this directory if you still
Read more
Installing Latex and Compiling a Latex Docuent in Linux
Posted onLatex is a popular document preparation system that is widely used for creating scientific and technical documents. Compiling Latex documents on Linux is a straightforward process that requires only a few Latex packages and a set of commands. By following the steps outlined in this post, you can easily compile Latex documents on your Linux
Read more
How to disable automatic comment insertion in Vim
Posted onHow to disable automatic comment insertion in Vim? Add to ~/.vimrc: au FileType c,cpp setlocal comments-=:// comments+=f:// More: http://vim.wikia.com/wiki/Disable_automatic_comment_insertion
Google Chrome keyboard and mouse shortcuts for Linux and Windows
Posted onWhat are the Google Chrome keyboard and mouse shortcuts for Linux and Windows? Keyboard shortcuts of Chrome can make it easier to control the browser and save our time. Here are a list of commonly used shortcuts: Ctrl+T Opens a new tab. Press Ctrl and click a link. Or click a link with your middle
Read more