Posts tagged linux
Fingerprint scanner on Thinkpad T440s under Linux – Ubuntu
To make the Lenovo Thinkpad t440s fingerprint scanner in Ubuntu (16.04.3) work, install the following:
sudo apt install fprintd libpam-fprintd
After the install – update the following file to set the timer to unlimited, otherwise the fingerprint scanner will time out during login:
sudo vi /etc/pam.d/common-auth
and look for the line that has the pam_fprintd in the name
auth [success=2 default=ignore] pam_fprintd.so max_tries=1 timeout=10
Usually the default is timeout=10 and max_tries=1, I updated mine like below, so it never times out and I have 2 tries
auth [success=2 default=ignore] pam_fprintd.so max_tries=2 timeout=-1
This works on sudo auth and login from lock, haven’t fully tested yet like startup etc. It is a little unstable though, I had it fail on me few times where it wouldn’t recognize the scanner anymore. I will update this post if I find anything.
Update heap size for Tomcat8 in Linux
If you install Tomcat8 (even tomcat7) via apt you will need to edit the file /etc/default/tomcat8 (or tomcat7) and look for the JAVA_OPTS variable. The Xmx value is there and you can set it as required.
Apache2 and php7 on Linux
To get apache2 working with php7 (or even lower perhaps?) on Linux you might need to download also the mod for php7
sudo apt-get install libapache2-mod-php7.0
Ubuntu 16.04.1 slows down while idle – kidle processes
Warning: the below might make your CPU run hotter or overheat – use at your own risk!
A new Ubuntu 16.04.1 installation – after short usage the computer slows down and the CPUs are about 50% busy. There are some kidle_inject processes running which take this valuable CPU.
Top shows the following:
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND 6898 root -51 0 0 0 0 S 47.1 0.0 1:20.16 kidle_inject/5 6900 root -51 0 0 0 0 S 47.1 0.0 1:20.38 kidle_inject/7 6894 root -51 0 0 0 0 S 41.2 0.0 1:13.55 kidle_inject/1 6895 root -51 0 0 0 0 S 41.2 0.0 1:16.90 kidle_inject/2 6896 root -51 0 0 0 0 S 41.2 0.0 1:18.28 kidle_inject/3 6897 root -51 0 0 0 0 S 41.2 0.0 1:18.64 kidle_inject/4 6899 root -51 0 0 0 0 S 41.2 0.0 1:20.02 kidle_inject/6 6893 root -51 0 0 0 0 S 29.4 0.0 1:08.23 kidle_inject/0
To stop these processes run the following command – it will disable them only for the current session. I very rarely reboot so I haven’t looked into making it permanent yet.
$ sudo rmmod intel_powerclamp
Enable export of all environment variables in bash
When setting up environment variables, for example in .profile you can write the following near the top of the file to enable exporting of all the environment variables without explicitly writing “export” each time:
set -o allexport
with the above, then you can just write the following, for example:
TEST_DIR=/tmp/test
instead of
export TEST_DIR=/tmp/test
To disable the all export:
set +o allexport
You are also able to set environment variables without the export or allexport, however that will NOT make the variable available to sub-processes.
Count bytes and characters with wc
Count bytes and characters with wc
wc -c filename == counts the bytes
wc -m filename == counts the characters
this can be combined with other commands like grep, awk, sed
example with sed:
sed -n '1p' filename | wc -c
the above will print the first line from filename and count the bytes in that line
Fix ^M in Linux/UNIX using vi/vim
Sometimes if you edit a file in windows and then open it in Linux/UNIX it will have the special characters ^M at the end of each sentence. To fix ^M in Linux/UNIX using vi/vim run the following:
%s/[ctrlkey+v and ctrl-key+M]//g
sed tricks to replace multi blank spaces and tabs with single space
Replace all multi-blankspaces (more than one spaces/tabs) in file with mono-blankspace (one space):
sed 's/[<space>][<tab>][<space>][<tab>]*/ /g' filename
can also be:
sed 's/[<space>][<tab>][<space>][<tab>]*/ /g' filename > newfilename
note: g in the end means GLOBAL
In the above samples, <space> means ‘ ‘ (empty space) and <tab> means ‘ ‘ (tab key press).
Sync servers using multiple streams with LFTP
If you have a remote server that you want to sync a directory you can use for example rsync, however rsync doesn’t offer the multi stream syncing and can be slower if you have many new files. The below solution uses lftp with 5 parallel streams to download and each stream is split into 10 separate segments. This is very helpful if you cannot max your download connection with regular methods and of course if the uploading server has enough bandwidth.
#!/bin/bash login=your_username pass=your_password host=sftp://download.redoem.com remote_dir=/media/files/redoem/dir local_dir=/home/redoer/downloads trap "rm -f /tmp/syncserver.lock" SIGINT SIGTERM if [ -e /tmp/syncserver.lock ] then echo "Syncserver is running already." exit 1 else touch /tmp/syncserver.lock lftp -u $login,$pass $host << EOF set ftp:ssl-allow yes set mirror:use-pget-n 10 mirror -c -P5 --newer-than=now-15min --log=syncserver.log $remote_dir $local_dir quit EOF rm -f /tmp/syncserver.lock trap - SIGINT SIGTERM exit 0 fi
The above sample should work for most cases – you just need to change the values of the variables (highlighted in red).
This part (–newer-than=now-15min) can be changed based on how old files you want to sync, for example if you synced the files 4 hours and you have new files in the last hour, you want to change this part to ONLY download the new files then change this part to be now-60min or more (but less than 4 hours in this example).
If you want to share from your local machine to the remote server, replace this line as (changed parts highlighted in red):
mirror -R -c -P5 --newer-than=now-15min --log=syncserver.log $local_dir $remote_dir
Now save the above as a .sh file, example syncserver.sh and you can add it as a cronjob to run every 15 minutes or run it when you have new files.
*/15 * * * * /home/redoer/syncserver.sh >> /home/redoer/sync_cron.log 2>&1
Enable Delete button in Gnome
By default the Delete button does not move files to trash, you need to use Ctrl+Delete which is major annoyance. This is after 3.2 Gnome I believe and still the same up to 3.10. They say it is a feature but I don’t see it as such.
To fix this, you will need to modify the accels of Gnome, with few simple steps:
Run the following in the terminal as your user:
gsettings set org.gnome.desktop.interface can-change-accels true
Now you are able to give items different buttons.
Select a file that you might want to delete (create New Folder for example) and after you have selected it, go to the Edit menu (right-click doesn’t work) and position your mouse over the Move To Trash field. Once the field is in focus, press the Delete button twice. The button combination on the right should be changed from Ctrl+Delete to Delete only.
That is all, now it is enabled. You should disable changing of accels now because you might accidentally do it for other things:
gsettings set org.gnome.desktop.interface can-change-accels false
This was tested on Gnome 3.4.2 on Debian Wheezy.
Recent Comments