JustToThePoint English Website Version
JustToThePoint en español
JustToThePoint in Thai

Linux terminal and administration

  1. Installation: sudo apt install tmux tmuxinator.
  2. All commands in Tmux start with a prefix, which by default is: Ctrl + b. You can start your first Tmux session by typing: tmux, but it is a better idea to create a new named session (you should use a descriptive name): tmux new -s session_name. You can detach from the session and return to your normal shell (Ctrl + b + d, detach), show all sessions (tmux ls), and attach to the last session (tmux attach) or to a named session (tmux a -t mysession). Finally, you kill the session: tmux kill-session -t mysession
  3. When you start a new session, it creates one window and a single panel inside. You can create a new window (kind of virtual terminals or desktops) by typing: Ctrl + b + c (create). You can switch to the previous window (Ctrl + b + p, previous), the next window (Ctrl + b + n, _n_ext) or directly to a particular window (Ctrl + b + number). You can close the current windows by typing: Ctrl + b + &.
  4. We can split the window into panes horizontally (Ctrl + b + “) or vertically (Ctrl + b + %). Next you may want to switch between panes: Prefix + ←, ↑, →, ↓. or kill a pane (Ctrl + b + x).
  5. Customizing Tmux (A more detail explanation in Making tmux Pretty and Usable by Ham Vocke). For that purpose, you must edit its configuration file: nvim ~/.tmux.conf
    # remap prefix from 'Ctrl-b' to 'Ctrl-a'
    unbind C-b
    set-option -g prefix C-a
    bind-key C-a send-prefix
    
    # Mouse compatibility
    set-option -g mouse on
    set -g set-clipboard on
    
    # split panes using Ctrl-h and Ctrl-v
    bind h split-window -h
    bind v split-window -v
    unbind '"'
    unbind %
    
    # switch panes using Alt-arrow without prefix
    bind -n M-Left select-pane -L
    bind -n M-Right select-pane -R
    bind -n M-Up select-pane -U
    bind -n M-Down select-pane -D
    
    # reload tmux conf with Prefix + r
    bind r source ~/.tmux.conf \; display "~/.tmux.conf sourced!"
    # command delay? No
    set -g escape-time 10
    ############################################
    ### DESIGN CHANGES (/u/dothebarbwa)      ###
    ############################################
    
    # loud or quiet?
    set -g visual-activity off
    set -g visual-bell off
    set -g visual-silence off
    setw -g monitor-activity off
    set -g bell-action none
    
    #  modes
    setw -g clock-mode-colour colour5
    setw -g mode-style 'fg=colour1 bg=colour18 bold'
    
    # panes
    set -g pane-border-style 'fg=colour19 bg=colour0'
    set -g pane-active-border-style 'bg=colour0 fg=colour9'
    
    # statusbar
    set -g status-position bottom
    set -g status-justify left
    set -g status-style 'bg=colour18 fg=colour137 dim'
    set -g status-left ''
    set -g status-right '#[fg=colour233,bg=colour19] %d/%m #[fg=colour233,bg=colour8] %H:%M:%S '
    set -g status-right-length 50
    set -g status-left-length 20
    
    setw -g window-status-current-style 'fg=colour1 bg=colour19 bold'
    setw -g window-status-current-format ' #I#[fg=colour249]:#[fg=colour255]#W#[fg=colour249]#F '
    
    setw -g window-status-style 'fg=colour9 bg=colour18'
    setw -g window-status-format ' #I#[fg=colour237]:#[fg=colour250]#W#[fg=colour244]#F '
    
    setw -g window-status-bell-style 'fg=colour255 bg=colour1 bold'
    
    # messages
    set -g message-style 'fg=colour232 bg=colour16 bold'
    
  6. We are going to use tmuxinator to create and manage tmux sessions easily.
  7. Let’s create a new project: tmuxinator new mySession. We can edit it later on with: tmuxinator edit mySession
  8. Layouts can be customized. If you want to get the custom layout for your current window, just type: tmux lsw -F “#{window_active} #{window_layout}” | awk ‘$1{print $2}’. In my case, it was 4a38,192x55,0,0{101x55,0,0,2,90x55,102,0,8}.
    # /home/$USER/.config/tmuxinator/mySession.yml
    name: mySession # Session's name and project
    root: ~/
    
    windows: # The windows option allows the specification of any number of tmux windows. We define three windows: first_window, system_info, and entertaining.
      - first_window:
          layout: main-horizontal # You can arrange panes in one of the five preset layouts: even-horizontal, even-vertical, main-horizontal, main-vertical, or tiled.
          panes: # Panes are optional and are children of window entries. We define the panes that get created inside each window. 
            - nvim myfile.txt # Under each pane, then we can give a command to execute.
            - cal
            - date
      - system_info:
          layout: tiled
          panes:
            - free -h
            - df -h
            - sensors
            - htop
      - entertaining:
          layout: 4a38,192x55,0,0{101x55,0,0,2,90x55,102,0,8} # We use the previous layout.
          panes:
              - is_justtothepoint_alive:
                  - ping -c 4 justtothepoint.com : # You can execute many commands in a pane, e.g., ping -c 4 justtothepoint.com, is justtothepoint.com alive?
                  - newsboat
              - music:
                  - radio
    
  9. Start a session: tmuxinator mySession
  10. Finally, we can remove a project (tmuxinator delete [project]), list all the projects (tmuxinator list), and kill the session (tmux kill-session -t mysession)
  1. You can install it in Ubuntu using the following command: sudo snap install alacritty ‐‐classic.

  2. Set Alacritty as your default terminal: sudo update-alternatives ‐‐install /usr/bin/x-terminal-emulator x-terminal-emulator /snap/bin/alacritty (you may have it in /usr/bin/alacritty -you should check it: whereis alacritty) 50 (priority). sudo update-alternatives ‐‐config x-terminal-emulator.

  3. Add a shortcut: Settings, Keyboard Shortcut, Custom Shortcuts. Name: Alacritty. Command: /snap/bin/alacritty. Set Custom Shortcut: Ctrl, Alt, and T.

  4. Visit Nerd Fonts. Choose your font, download it, and copy it into ~/.local/share/fonts. Update the font cache: fc-cache -f

    Install more fonts: sudo apt install ttf-mscorefonts-installer fonts-cantarell lmodern ttf-aenigma ttf-bitstream-vera ttf-sjfonts ttf-unifont fonts-entypo fonts-isabella fonts-mplus fonts-prociono ttf-anonymous-pro ttf-engadget ttf-staypuft ttf-summersby

  5. Let’s configure it by editing its configuration file: vim /home/user/.config/alacritty/alacritty.yml

# Window Customization
window:   # Window dimensions (changes require restart)
  decorations: none # Neither borders, nor title bar.
  startup_mode: Fullscreen 
scrolling: # Maximum number of lines in the scrollback buffer. It contains all the text that has been displayed on the screen.
  history: 10000
  multiplier: 3
background_opacity: .95 # Window opacity as a number from `0.0` (completely transparent) to `1.0` (opaque)
window.dynamic_title: true # Allow terminal applications to change Alacritty's window title.
# Font Customization
font:
  normal:
    family: MesloLGS NF
    style: Regular
  bold:
    family: MesloLGS NF
    style: Bold
  italic:
    family: MesloLGS NF
    style: Italic
  size: 12 # Text size
  offset:
    x: 0
    y: 0
  glyph_offset:
    x: 0
    y: 0
  use_thin_strokes: false
  debug:
    persistent_logging: false
draw_bold_text_with_bright_colors: true
# Colors (Gruvbox dark) https://github.com/eendroroy/alacritty-theme
colors:
  primary:
    background: '#000000'
    foreground: '#ebdbb2'
  normal:
    black:   '#282828'
    red:     '#cc241d'
    green:   '#98971a'
    yellow:  '#d79921'
    blue:    '#458588'
    magenta: '#b16286'
    cyan:    '#689d6a'
    white:   '#a89984'
  bright:
    black:   '#928374'
    red:     '#fb4934'
    green:   '#b8bb26'
    yellow:  '#fabd2f'
    blue:    '#83a598'
    magenta: '#d3869b'
    cyan:    '#8ec07c'
    white:   '#ebdbb2'
selection:
    semantic_escape_chars: ",?`|:\"' ()[]{}<>\t"
    text: '0xffffff'
    background: '0xdc3232'
    white:   '0xffffff'
    save_to_clipboard: true  # When set to `true', selected text will be copied to the primary clipboard.

key_bindings:
  - { key: V, mods: Control, action: Paste } # Crtl + V = Paste
  - { key: C, mods: Control, action: Copy } # Crtl + C = Copy
  - { key: NumpadAdd, mods: Control, action: IncreaseFontSize } # Ctrl + "+", increase terminal's text size.
  - { key: NumpadSubtract, mods: Control, action: DecreaseFontSize } # Ctrl + "-", decrease terminal's text size.
  - { key: N, mods: Control, action: SpawnNewInstance }  # Ctrl + N, it creates a new instance.
  - { key: W, mods: Control, action: ToggleFullscreen } # Ctrl + W, toggle full screen terminal.
  - { key: F1, mods: Control, chars: "{" } # Barrier cannot type character that need Alt Gr key.
  - { key: F2, mods: Control, chars: "}" }
  - { key: F3, mods: Control, chars: "#" }
  - { key: F4, mods: Control, chars: "~" }
  - { key: F5, mods: Control, chars: "@" }
  - { key: F6, mods: Control, chars: "|" }

Cool Command Line Tools For Your Linux Terminal

You can change Neofetch’s config file (nvim .config/neofetch/config.conf) to customize it and display exactly what you want it to. We need to modify the .bashrc file to be able to use powerline, vi .bashrc”:

if [ -f /usr/share/powerline/bindings/bash/powerline.sh ]; then     
  source /usr/share/powerline/bindings/bash/powerline.sh 
fi 
neofetch 
fortune | cowsay
Terminal in GNU/Linux

Terminal in GNU/Linux

set preview_images true # preview images in ranger 
set preview_images_method ueberzug # pip install ueberzug 
default_linemode devicons # git clone https://github.com/alexanderjeurissen/ranger_devicons ~/.config/ranger/plugins/ranger_devicons. File icons for Ranger. It prefixes file names with a file icon. 
set show_hidden true # show hidden files/directories
  1. The command man is the general help. Some examples are: man ps, man fdisk. tldr (aka “Too Long Didn’t Read") are simplified and community-driven man pages with practical examples. Installation: sudo apt install tldr. Update offline cache of tldr pages: tldr ‐‐update. Use: tldr grep.
  2. You could get access to the best community driven cheat sheets by typing: curl https://cht.sh/ps, curl https://cht.sh/fdisk. You may also want to check: Cheat Sheet.
  3. apropos: it helps you when you don’t remember the exact command but a keyword related to it, e.g. apropos firewall.
  4. And last, but not least, cheat allows you to create and view interactive cheatsheets on the command-line: sudo snap install cheat. Use: cheat tail. First time: A config file was not found. Would you like to create one now? Y. Would you like to download the community cheatsheets? Y. To edit a cheatsheet: cheat -e tail.

Clean System and Maintenance: gedit /root/.bashrc: alias mantaining=’sudo apt-get update (it resynchronizes the package index files from their sources)

  1. && apt-get -y upgrade (it installs the newest versions of all packages currently installed on the system)
  2. && apt-get -y autoremove (it removes packages that were automatically installed to satisfy dependencies for other packages and are now no longer needed)
  3. && apt-get -y clean (it cleans out the cache of retrieved package files. It removes the files that are no longer required but are still residing on your system)
  4. && rm -rf ~/.cache/thumbnails/* (Clear the thumbnail cache. For each displayed picture, Ubuntu automatically creates a thumbnail for viewing in the file manager)
  5. && updatedb (it creates or updates a database used by locate.

    The “locate” command is the fastest way of searching: locate fileName. The reason is that it is not actually searching your local hard disks, but reads through the mlocate.db database file which contains all file paths in your system). Another slower alternative to find files is: find . -name “fileName

  6. && sudo bleachbit ‐‐clean system.cache system.localizations system.trash system.tmp’
  1. Installation: sudo apt install stacer.
  2. Run it: stacer: Dashboard, Startup Apps (applications the system launches at boot time), System Cleaner, Services (it allows you to start and stop system services), Processes, Uninstaller, Resources (CPU, CPU Load Averages, Disk Read Write, Memory, Network), APT Repository Manager. stacer

    stacer

    You can kill processes by name using killall, e.g., killall gimp. What should you do when your Linux desktop freezes or a program stops working? 1. Open a terminal: Ctrl + Alt + T. 2. Type xkill, hover your cursor (it should have turned into an X) over the program and do a left-click to kill it. 3. If that does not work, type Ctrl+Alt+F1.

Configure keyboard shortcuts: gedit ~/.config/kitty/kitty.conf:

font_family MesloLGS NF 
copy_on_select yes # it will copy selected text into the clipboard) 
map ctrl+c copy_to_clipboard # CTRL + C: Copy to clipboard
map ctrl+v paste_from_clipboard #CTRL + V: Paste from clipboard
background_opacity 0.9.

If you find problems with ssh (remote server): gedit .bashrc, export TERM=vt100.

On the other side, you can enter calcurse’s interactive Configure mode by pressing c; pressing c again will lead you to the Color scheme configuration (it displays possible choices for foreground and background colors). If you type l, it will allow you to choose the layout of the main calcurse screen (you can decide where to put the three panels -Appointments, Calendar, and To-do- on your screen).

Finally, typing g allows you to edit its General Options (it controls calcurse’s general behavior): format.outputdate = %d/%m/%y (day/month/year).

Bitcoin donation

JustToThePoint Copyright © 2011 - 2022 PhD. Máximo Núñez Alarcón, Anawim. ALL RIGHTS RESERVED. Bilingual e-books, articles, and videos to help your child and your entire family succeed, develop a healthy lifestyle, and have a lot of fun.

This website uses cookies to improve your navigation experience.
By continuing, you are consenting to our use of cookies, in accordance with our Cookies Policy and Website Terms and Conditions of use.