Table of contents
If you experience strange behavior in your terminal (for example, the columns of the ls command are misaligned or there is no line wrap in long commands), run the magic command reset. Most likely your problems will be solved!!
xfce4-session-settings
./configure --prefix=/dummy/path make # -j $NCPUS make install find /dummy/path -type f -print > install_manifest.txt find /dummy/path -type d -print >> install_manifest.txt xargs rm < install_manifest.txt rm -r /dummy/path
Remember: you may need sudo powers depending on the original install path.
./configure --prefix=/custom/path. More at https://www.baeldung.com/linux/change-install-dir-make-install
awk -F: '{ print $1}' /etc/passwd cut -d: -f1 /etc/passwd cat /etc/passwd | grep root | awk -F: '{ print $1}' cat /etc/passwd | grep root | cut -d: -f1
If you get ImportError: libgfortran.so.3: cannot open shared object file: No such file or directory when running python with numpy, try reinstalling numpy (eg., pip install --user -U numpy).
ps -ef | grep {name} | grep -v grep | awk '{print $2}'
It is stored at /home/$USER/.local/share/Trash . From https://askubuntu.com/questions/102099/where-is-the-trash-folder
TBC if it works: https://www.how2shout.com/linux/how-to-install-oracle-java-8-64-bit-ubuntu-22-04-20-04-lts/
# URL taken from https://aur.archlinux.org/packages/ttf-wps-fonts wget https://github.com/IamDH4/ttf-wps-fonts/archive/master.zip unzip master.zip sudo mkdir /usr/share/fonts/wps-fonts sudo mv ttf-wps-fonts-master/* /usr/share/fonts/wps-fonts sudo chmod 644 /usr/share/fonts/wps-fonts/* sudo fc-cache -vfs rm -rf ttf-wps-fonts-master
My machine "orion" is running a VirtualBox VM "orionVM".
In Virtualbox, if I set the following port forwarding: Rule 1 | TCP | 127.0.0.1 | 2222 | 10.0.2.15 | 22, then I will be able to do the following:
@orion $ ssh -p2222 {localhost|127.0.0.1} # connects to orionvm !! # it won't work with {orion}
If I add the network IP for orion in the Virtualbox Rule 1 | TCP | {networkIP} | 2222 | 10.0.2.15 | 22, I can use ssh -p2222 orion.
There is a network machine "nebula" that "orionVM" can not access, but "orion" can. The command below will enable "orionVM" to access "nebula:22" using "orion:2222":
@orion $ ssh -N -C -L *:2222:nebula:22 orion @orionVM $ ssh -p2222 orion
More info at https://serverfault.com/questions/910526/ssh-local-port-forwarding-working-from-localhost-only
# Tunnel creation -- Docker ssh -i ~/.ssh/file.pem -NL localhost:2374:/var/run/docker.sock user@machine & # Access tunnel docker -H localhost:2374 info
Using Tomcat as an example
More on apache-tomcat installation at https://computingforgeeks.com/install-apache-tomcat-9-on-linux-rhel-centos/
lsblk free -m df -Th cat /etc/redhat-release ip addr show ethtool em1
PATH=$(echo "$PATH" | sed -e 's/\/home\/wrong\/dir\://')
iostat and dstat -d do the job. dstat (without flags) monitor different points: https://www.networkworld.com/article/3330497/linux-commands-for-measuring-disk-activity.html
Newer systems (~2015+) require two additional partitions:
The rest remains the same since the DOS era.
rm CMakeCache.txt cmake .. make prefix=$HOME/.local/ make DESTDIR=$HOME/.local/ install
sudo nano /sys/class/backlight/intel_backlight/brightness # set the value to 1
sudo mount /path/to/file.iso /path/to/mount -o loop #-t udf #-t iso9660 sudo umount /path/to/mount
mkisofs -o new.iso /path/to/folder
dd if=/dev/cdrom of=/home/user/new.iso
One may also want to clean up the previous authorizations. For that, Options > Content > Notifications > Choose... > Remove All Sites > Save Changes.
apt-file: https://wiki.ubuntu.com/AptFile . This is very useful when looking for Latex files, as *.sty.
7za a -m0=Copy -v512m output.7z input 7za a -m0=lzma2 -mx0 output.7z input # -mx=[0|1|3|5|7|9] 5 Sets level of compression. # 0 = copy; 1 = fastest; 5 = default; 9 = max.
unrar x -kb damaged.rar
mplayer (mplayer2) is the best!
sed -i "s/INPUT/OUTPUT/g" *.txt
Reminder: if you want to substitute a special character, write "\" before it (e.g., "\/").
alias ls # alias ls='ls --color=auto'
du -h(s) folder
Returns the disk usage of folder recursively. "s" returns it summed.
Good program: baobab.
ls -ltr --time-style=long ls -ltr --time-style=iso ls -ltr --time-style=full
`awk` tool for processing rows and columns. `bc` calculate mathematical expressions. `cat` print the whole file on screen. `cd` change your current directory. `chgrp` change the group of the file. `chmod` change permissions of the file. `chown` change the owner of the file. `cp` copy a file. `cut` select sections of text files (usually cols) by delimiters. `date` print the current date on screen. `diff` shows in screen the differences between two files. `du` get information about disk usage and file sizes. `echo` print string on screen. `expr` calculate mathematical expressions. `find` find files in your computer. `grep` find string in file or list of files. `gzip` compress/decompress files. `head` print first lines of a file. `ifconfig` check network info (IP, mac address...). `ln` create links (shortcuts) between files. `ls` list files in directories. `mkdir` create a directory. `more` print file on screen, pause in the way. `mv` move files from directories and change their names. `nohup` leave process running in remote computer after you log off `passwd` change your password. `read` get input from keyboard. `rm` remove (delete) a file. `scp` copy files to/from remote computers. `sed` automatable, command-line text editing. `shred` write zeroes on top of the file so it cannot be recovered. `sort` sort lines in a text file. `ssh` connect to remote computers. `tac` print the whole file on screen, backwards. `tail` print last lines of a file. `tar` put/extract files in a tarball. `touch` update 'last modified' date or create an empty file. `wc` counts words, lines and characters in a file. `wget` download file from the internet. `top` find out which processes are running. `xargs` pass input from pipeline as argument to a command.
# examples cat command_list.txt more command_list.txt head command_list.txt head -n3 command_list.txt head -n-20 command_list.txt tail command_list.txt tail -n3 command_list.txt tail -n-20 command_list.txt diff command_list.bkp command_list.txt wc command_list.txt wc -m command_list.txt wc -l * grep "example:" command_list.txt grep "List of examples" -A6 command_list.txt grep "List of examples" -A6 -m1 command_list.txt grep -nr "example:" command_list.txt grep -v "example:" command_list.txt grep "Other" command_list.* grep "Other" command_list.* -l grep "Other" command_list.* -c grep --help sort data/frutas.dat sort -n data/numeros.dat cut -d: -f1 command_list.txt cut -d/ -f3 data/listagem.dat awk '{print $2,$1}' data/listagem.dat sed -e "s/example/exemplo/g" -e "s/:/>/g" command_list.txt find ./ -name '*.dat' ln -s data/numeros.dat numbers.dat nohup <normal command> > output.txt & chmod 755 helloworld.sh
ln -s {/path/to/file-name} {link-name}
nproc
find . -name "*~" -exec rm -r "{}" \; # or find . -name "*~" -print0 | xargs -0 rm # or for directories find . -name "svn" -type d -exec rmdir "{}" \;
rsync -azP --delete --dry-run --rsh='ssh -p20001' Scripts/ user@machine:/paht/Scripts2 # "/" = very important. Otherwise, without "/", it goes /paht/Scripts2/Scripts # -a = arquive (recursive) # -z = zip (for network) # --delete = to sync deletions # --dry-run = only show results # -P = partially (resume) # --exclude X = ignora arquivos X, e.g. "*.pro" # --update = somente sobrescreve arquivos mais novos # --stats = estatistica da transferencia rsync -a -f '- /*/*/' /dirA/ host:/dirB/ # -a triggers the archive mode that activates recursion # -f is short for --filter=, which adds a file-filtering rule. # The pattern is inside single quotes so that the shell does not expand # wildcards; double quotes would work equally well in this case. # - means this is an exclude pattern. # The leading / means the pattern must start at dirA/ (the rsync "transfer-root"). # The */* part of the pattern refers to anything inside of a subdirectory. # The trailing / limits the exclusion to directories. # Files inside a subdirectory of dirA/ are not affected. # So in the end, rsync copies nothing more than one level down (and also does not # create second-level directories).
/etc/environment is not part of POSIX, it belongs to PAM (Pluggable Authentication Module), and only programs compiled with PAM support are able to use it (primarily login systems, which subsequently start the shell or user environment). This means it isn't even read by your shell.
You can see the programs using /etc/environment with grep -l pam_env /etc/pam.d/*.
So /etc/environment is used for setting variables for programs which are usually not started from a shell.
Also works on Mac OS.
Script starts with #!/bin/bash
After opening then with program &, just type disown.
exaile -t #Pause exaile -p #Previous exaile -n #Next qmmp -t #Pause clementine -t #Pause clementine -r #Previous clementine -f #Next amixer set Master 7%- -q amixer set Master 7%+ -q
sudo apt-get install imagemagick mogrify -quality 75 * # Para mudar a resolucao, onde nao havera nenhuma imagem com largura ou # altura maior do que 1280 pxs (O 'aspect ratio' eh sempre preservado): mogrify -resize '1280x1280>' *.jpg # Exemplos: 4608x3072 -> 1280x852 # Exemplos: 3072x4608 -> 852x1280 mogrify -resize '1920x1920>' -quality 75 *.jpg mogrify -resize '1920x1920>' -quality 75 *.JPG # fusao vertical convert -gravity Center -append input*.eps output.png # fusao horizontal convert -gravity Center +append input*.eps output.png # Exemplo mais avancados montage rrm.pdf pol.pdf -geometry 800x800 output.pdf convert output.pdf -crop 1600x600+0+100 +repage out2.pdf convert teste.pdf -crop 100%+0+10% +repage out2.pdf montage vin.pdf xav.pdf -geometry 600x600 temp.pdf convert temp.pdf -crop 1200x460+0+70 +repage newfig1.pdf
In principle, one could use convert for the job. However, it is annoying aligning and setting border. So, I suggest using img2pdf.
img2pdf input.png --pagesize 210mmx297mm --border 1cm:2.5cm -o out.pdf # --pagesize 210mmx297mm force the portrait mode. # For landscape (or "auto"), use --pagesize A4.
There are several recipes for doing this (e.g., convert img.png img.eps). By far, the best option is this:
convert image.png image.pdf pdftops -eps image.pdf
You can also try (eps3 is a valid option):
convert image.png eps2:image.eps
Attention! BIMP and David's Batch Plugin (gimp-plugin-registry) DO NOT WORK for EPS format...
(More about EPS-PDF convertion, formats and sizes, see latex page)
sudo vim /etc/default/grub sudo update-grub
Using the terminal (command line)
sudo dpkg-reconfigure tzdata
Follow the directions in the terminal. The timezone info is saved in /etc/timezone.
On Xubuntu 16.04, if the indicator-multiload has problems ("transparency") or the volume indicator is missing, You might have indicator-plugin missing from the panel.
Right click on the panel and select it.
Install multiload-ng!!!!
sudo add-apt-repository ppa:nilarimogard/webupd8 sudo apt update sudo apt install xfce4-multiload-ng-plugin
Then, (right click) Panel > Panel Preferences > (tab) Items > "+"
In Ubuntu, the program-file type association is set is in ~/.local/share/applications/mimeapps.list.
Then, the program associated there must have a "description" in /usr/share/applications/PROGRAM.desktop.
One example is here:
[Desktop Entry] Name=Foxit Reader Comment=View pdf documents Keywords=pdf;octet-stream; StartupNotify=true Terminal=false Type=Application #Icon=FoxitReader X-GNOME-DocPath= X-GNOME-Bugzilla-Bugzilla=GNOME X-GNOME-Bugzilla-Product=FoxitReader X-GNOME-Bugzilla-Component=BugBuddyBugs X-GNOME-Bugzilla-Version=3.14.1 Categories=GNOME;Viewer;Graphics;2DGraphics;VectorGraphics; MimeType=application/pdf;application/octet-stream; Exec=/data/Softwares/Foxit/FoxitReader.sh Icon=/home/user/.local/share/icons/hicolor/64x64/apps/FoxitReader.png
Network or wifi passwords are saved in /etc/NetworkManager/system-connections. There is a file for each connection with its configuration and password. One need root privileges to read them (the files aren't encrypted).
To mount a filesystem with special user id set, use bindfs.
sudo apt-get install bindfs mkdir ~/myUIDdiskFoo sudo bindfs -u $(id -u) -g $(id -g) /media/diskFoo ~/myUIDdiskFoo # Keep the default mount running (do not eject)
More information: - http://www.penguintutor.com/linux/file-permissions-reference - https://askubuntu.com/questions/34066/mounting-filesystem-with-special-user-id-set/353759#353759
Open about:config in Firefox, and change the option at extensions.adblockplus.sidebar_key!
chmod a[ll],g[roup],u[ser] +/-x,r,w 1 = execute 2 = write 4 = read 7 = 1+2+4
To do it recursively:
# To recursively give directories read&execute privileges: find /path/to/base/dir -type d -print0 | xargs -0 chmod -f 775 # To recursively give files read privileges: find /path/to/base/dir -type f -print0 | xargs -0 chmod 664 # # Other (not so efficient) ways are: find /path/to/base/dir -type d -exec chmod 755 {} + find /path/to/base/dir -type f -exec chmod 644 {} + # Or chmod 755 $(find /path/to/base/dir -type d) chmod 644 $(find /path/to/base/dir -type f)
chmod g+s <directory> //set gid setfacl -d -m g::rwx /<directory> //set group to rwx default setfacl -d -m o::rx /<directory> //set other
Next we can verify:
getfacl /<directory>
Output:
# file: ../<directory>/ # owner: <user> # group: media # flags: -s- user::rwx group::rwx other::r-x default:user::rwx default:group::rwx default:other::r-x
Error message when I run sudo: unable to resolve host(name)
$ ssh-keygen -t rsa #(3x type ENTER) #Your public key has been saved in <your_home_dir>/.ssh/id_rsa.pub $ scp ~/.ssh/id_rsa.pub USER@HOST:/sto/home/USER/id_rsa.pub #(Type your server's password)
$ cat id_rsa.pub >> ~/.ssh/authorized_keys $ chmod 700 ~/.ssh/authorized_keys $ rm id_rsa.pub
$ exec ssh-agent bash $ ssh-add
git config --global user.name "John Doe" git config --global user.email johndoe@example.com
https://help.github.com/articles/generating-ssh-keys/
ssh-keygen -t rsa -b 4096 -C "user@gmail.com" # Enter file in which to save the key (/home/user/.ssh/id_rsa): /home/user/.ssh/id_github # # Type your github password... # # ... # The key fingerprint is: # 01:0f:f4:3b:ca:85:d6:17:a1:7d:f0:68:9d:f0:a2:db user@gmail.com cat /home/user/.ssh/id_github.pub # Copy and paste the PUBLIC key to https://github.com/settings/ssh # These steps may be required: # .. # start the ssh-agent in the background # eval "$(ssh-agent -s)" # Agent pid 59566 # # If ~/.ssh/id_rsa do not exists: # ssh-keygen -t rsa # # Add your SSH key to the ssh-agent: # ssh-add ~/.ssh/id_rsa
Press "Record" and then check the "Recording" tab at the volume control.
Look for the "Monitor..." option.
A software that can do this is called sox. It has an option for karaoke:
oops
Out Of Phase Stereo effect. Mixes stereo to twin-mono where each mono channel contains the difference between the left and right stereo channels. This is sometimes known as the ‘karaoke’ effect as it often has the effect of removing most or all of the vocals from a recording.
So from command line this ...
sox song.wav song_karaoke.wav oops
It must be in the WAV format.
To work directly on the MP3, you can also use audacity.
http://manual.audacityteam.org/o/man/tutorial_vocal_removal_and_isolation.html
Sound card automaticly change to hdmi output when two applications conflicted with it. I fix that with the following command. It restore output to analog, again.
alsactl -F restore
By default, we cannot hear any sound of microphone over speaker on Debian or Ubuntu OS. So, we cannot sing karaoke. But this command can route the mic input through output:
pactl load-module module-loopback latency_msec=1
To turn it off:
# Find the module NUMBER with pacmd list-modules # then to unload it: pactl unload-module 27
To add this permanently, you need to load the module when pulseaudio starts. To do this, you need to add a line to the /etc/pulse/default.pa (as sudo). The line can be added at the end of the file:
load-module module-loopback
PROBLEM: there is a lag in the mic audio using this method.
sudo apt-get install qjackctl
Maybe you will need to add your user to the audio group (and restart the system).
To use it, "Start" and then "Connect".
PROBLEM: No system audio - but no lag!
Open you file in the Audacity.
Record your mic. The problem is: or you listen to yourself (and set out of sinc with the music, like with loopback) or listen only to the music.
I couldn't find a way record the voice while playing it in the right time (only with lag).
QjackCtl: mic in the output, no lag. No system sound, and no record.
Audacity + loopback: mic in the output, with lag. System sound, and record.
Audacity: no mic in the output. System sound and record, no lag.
https://unix.stackexchange.com/questions/12227/setting-a-name-for-a-screen-session
screen -rd does the job
https://unix.stackexchange.com/questions/240444/cant-resume-screen-says-i-am-already-attached
If I open a screen on my local machine and ssh into a remote one, if I try to open a screen on remote I receive the following error message: Cannot find terminfo entry for 'screen.xterm-256color'.
However, if I ssh into remote from a local terminal, screen on remote works fine :-)
Your friend: https://crontab.guru/
crontab is the command that loads and runs a set of cron jobs.
The {cronfile} will be something like this:
# Please do not edit the crontab directly (crontab -e) # # Syntax: # minute (0-59) # hour (0-23) # day (0-31) # month (0-12) # day of the week (0-6, 0=Sunday) # SHELL=/bin/bash # BASH_ENV=/home/dataproc/cron_bash MAILTO=user@my.company.com #* 8-17 * * 1-5 rsync -avq machine:/home/user/shared/ ~/mnt/ 2> msg_in.log