Skip to content

SysTutorials

  • Tutorials
  • Linux
  • Linux Manuals
  • Systems
  • Programming
  • Software
  • Subscribe
  • Search
SysTutorials

  • QA

    How to test whether PATH has a specific directory in it in Bash on Linux?

    ByEric Ma Mar 24, 2018Mar 24, 2018

    How to test whether PATH has a specific directory in it in Bash on Linux? For example, how to test whether /usr/local/mytool/bin is in $PATH? Directories in the $PATH variable are separated by :. So you can use a regular expression to test whether the $PATH contains a directory. The code for your specific example…

    Read More How to test whether PATH has a specific directory in it in Bash on Linux?Continue

  • QA

    How to get another user’s PATH in Bash on Linux?

    ByEric Ma Mar 24, 2018Mar 24, 2018

    How to get the $PATH environment variables of another user in Bash on Linux? The current user running the Bash script is root. If the scripts is run by root, this piece of code will store the PATH from the environment of the user user1: user1path=$(su – $user1 -c env | grep ^PATH= | cut…

    Read More How to get another user’s PATH in Bash on Linux?Continue

  • QA

    How to test a file or directory exists in Python?

    ByEric Ma Mar 24, 2018Mar 24, 2018

    In Bash, the [ -f ] and [ -d ] tests can test whether a file or a directory exist. What are the corresponding python method for these tests? For -f: **os.path.isfile(path)** Return True if path is an existing regular file. This follows symbolic links. For -d: **os.path.isdir(path)** Return True if path is an existing…

    Read More How to test a file or directory exists in Python?Continue

  • QA

    How to get file extension in JavaScript?

    ByEric Ma Mar 24, 2018Mar 24, 2018

    How to get file extension from a file name in JavaScript? For examples, For “file.txt”, I want to get “txt”. For “file2.multi.ext.fileext”, I want to get “fileext”. This JavaScript function works well for me. function getExt(filename) { var idx = filename.lastIndexOf(‘.’); // handle cases like, .htaccess, filename return (idx < 1) ? “” : filename.substr(idx…

    Read More How to get file extension in JavaScript?Continue

  • QA

    How to config Git remote server on Bitbucket or Github

    ByWeiwei Jia Mar 24, 2018Jan 7, 2020

    For your first push with git, you may get following errors when you use github or bitbucket. $ git push No refs in common and none specified; doing nothing. Perhaps you should specify a branch such as ‘master’. fatal: The remote end hung up unexpectedly Everything up-to-date Just run following command to set your remote…

    Read More How to config Git remote server on Bitbucket or GithubContinue

  • QA

    How to scp multiple files from remote to local on Linux?

    ByEric Ma Mar 24, 2018Mar 24, 2018

    With scp, copying several files such as file1 file2 to remote site can be passed by command line like $ scp file1 file2 user@remote: But how to scp multiple files from remote to local on Linux? You can do similar things by at least 2 method with scp: $ scp user@remote:file{1,2} ./ $ scp user@remote:”file1…

    Read More How to scp multiple files from remote to local on Linux?Continue

  • QA

    How to move cursor to a specific byte in Vim?

    ByEric Ma Mar 24, 2018Mar 24, 2018

    In Vim, ’20G’ moves the cursor to line 20 in command mode. But how to move the cursor to a specific byte in Vim? In normal mode, 20go will move the cursor to byte 20. Or in command line, :goto 20 or :go 20 From vimdoc: :[range]go[to] [count] [count]go Go to {count} byte in the…

    Read More How to move cursor to a specific byte in Vim?Continue

  • QA

    How to test whether a user already exist on Linux?

    ByEric Ma Mar 24, 2018Mar 24, 2018

    How to test whether a user account, say linuxuser, already exist on Linux? You may make use of id which tries to get user IDs. The Bash code snippet is as follows. user=hello id -u $user >/dev/null 2>&1 if [ “$?” == “0” ]; then echo “user $user already exist.” else echo “user $user doesn’t…

    Read More How to test whether a user already exist on Linux?Continue

  • QA

    How to get the script’s own path in sourced Bash script?

    ByEric Ma Mar 24, 2018Mar 24, 2018

    In normal Bash script, $0 is the path to the script. However, when a script is sourced, such as . a.sh a.sh’s $0 does not give a.sh. How to get the a.sh inside a.sh? Short answer: use ${BASH_SOURCE[0]}. You can check this post for details and explanations: How to Get Bash Script’s Own Path.

    Read More How to get the script’s own path in sourced Bash script?Continue

  • QA

    How to get a user’s home directory from the username in a variables in Bash?

    ByEric Ma Mar 24, 2018Mar 24, 2018

    In Bash, ~username gives the username user’s home. However, this does not work for situations where username is in a variable such as ~$user How to get the home directory from the user name in a variable in Bash? You can use this Bash script snippet: userhome=$(eval echo ~$user) Here, $user get evaluated to its…

    Read More How to get a user’s home directory from the username in a variables in Bash?Continue

  • QA

    How to enable natual scroll of touchpad in MATE on Linux?

    ByEric Ma Mar 24, 2018Mar 24, 2018

    There are options for Gnome 3 and Cinnamon to make touch pad “natual scroll”. But in MATE, there is no such options in its “Mouse” control options. How to enable natual scroll of touchpad in MATE on Linux? You may manually set the change of your ‘scrolls’ from the touch pad to negative values using…

    Read More How to enable natual scroll of touchpad in MATE on Linux?Continue

  • QA

    How to install MATE on Linux Mint 17 Qiana?

    ByEric Ma Mar 24, 2018Mar 24, 2018

    I am using Linux Ming 17 Qiana. How to install MATE on Linux Mint 17? In Linux Mint, the package that installs MATE is ‘mint-meta-mate’: $ sudo aptitude install mint-meta-mate

    Read More How to install MATE on Linux Mint 17 Qiana?Continue

  • QA

    How to generate a CSR from a private SSL key?

    ByEric Ma Mar 24, 2018Mar 11, 2019

    I am renewing my SSL key for my websites. The CA requests a CSR. I have my private key. How to generate a CSR (Certificate Signing Request) from a private SSL key? You can generate a CSR from your private key with openssl: openssl req -new -key ssl.key -out req.pem Here, ssl.key is your private…

    Read More How to generate a CSR from a private SSL key?Continue

  • QA

    In Vim, how to search and replace in visual selection?

    ByEric Ma Mar 24, 2018Mar 24, 2018

    Search and replace in the whole text in Vim can be done by :%s/from/to/gc. But how to search and replace in visual selection only? The %V atom in Vim restricts a pattern so that it matches only inside the visual selection. So, your command for searching and replacing only in the visual selection can be…

    Read More In Vim, how to search and replace in visual selection?Continue

  • QA

    How do I force Linux to unmount a filesystem?

    ByEric Ma Mar 24, 2018Mar 24, 2018

    Some time, Linux fails to unmount a filesystem reporting “device is busy”. I understand that this helps avoid data lost by disallowing unmouting a filesystem when it is being used. But for some situations, I am sure there is something wrong happened or I care not data lost, such as a NFS mounting while the…

    Read More How do I force Linux to unmount a filesystem?Continue

  • QA

    How to manually set Vim’s filetype?

    ByEric Ma Mar 24, 2018Mar 24, 2018

    Vim can detects the file types from quite well. But under certain situations, such as creating a new file, Vim does not automatically set the file type. How to manually set it? In side Vim, to set a filetype, set value to the filetype variable. For example, to set the filetype to php: :set filetype=php

    Read More How to manually set Vim’s filetype?Continue

  • QA

    Linux boots failed with “sulogin: can not open password database” while the /etc/passwd and /etc/shadow files look fine

    ByEric Ma Mar 24, 2018Mar 30, 2026

    Linux boots failed with “sulogin: can not open password database” while the /etc/passwd and /etc/shadow files look fine. How to fix this? The OS is Fedora 41. You may try this trick Step 1: boot Linux with rw init=/bin/bash following this tutorial. Step 2: after Linux booted, disable SELinux following this tutorial. Reboot. If it…

    Read More Linux boots failed with “sulogin: can not open password database” while the /etc/passwd and /etc/shadow files look fineContinue

  • QA

    How to get the top committers in git?

    ByEric Ma Mar 24, 2018Jan 24, 2020

    How to get the top committers in git? Like in github: But plain text is fine showing number of commits and author names/emails sorted by the number of commits. You may use this command: git log | grep Author | sort | uniq -c | sort -n -r Here, count the number of commits by…

    Read More How to get the top committers in git?Continue

  • QA

    How to debug media print view of Web page in Firefox?

    ByEric Ma Mar 24, 2018Mar 24, 2018

    How to debug the media print view set by @media print {} in CSS of Web pages in Firefox? In firefox, after opening the Web page, First, hit “Shift + F2” to open the “Developer Toolbar” at the bottom. Second, in the “Developer Toobar”, input media emulate print and Firefox will show the print view…

    Read More How to debug media print view of Web page in Firefox?Continue

  • QA

    How to get the latest git commit SHA-1 in a repository?

    ByEric Ma Mar 24, 2018Oct 7, 2019

    How to get the latest git commit SHA-1 id in a repository? And how to get the first 8 digits of the SHA-1? Instead of the method introduced here, you may use $ git rev-parse HEAD to get the commit SHA-1 hash ID. If you want to get the first 8 digits only, use $…

    Read More How to get the latest git commit SHA-1 in a repository?Continue

Page navigation

Previous PagePrevious 1 … 19 20 21 22 23 … 70 Next PageNext

© 2026 SysTutorials

  • Tutorials
  • Linux
  • Linux Manuals
  • Systems
  • Programming
  • Software
  • Subscribe
  • Search