Skip to content

Instantly share code, notes, and snippets.

@rplaurindo
Last active January 10, 2023 00:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rplaurindo/8515102 to your computer and use it in GitHub Desktop.
Save rplaurindo/8515102 to your computer and use it in GitHub Desktop.
Linux utils

Shell Commands

System informations

$ lsb_release -a

Discovering the UUID of a device

Run

$ sudo blkid /dev/<partition label>

Finding a word between all returned after a command execution

$ <command> | grep <word>

Finding a word over just a file or over one or more files of a folfer

$ grep -PHnor '<pattern>' <folder or file>

To show whole line, remove -o.

Finding file path through its name

$ sudo find <starting path> -iname <file name>

Finds a service which is in a particular port

Run

$ lsof -i <port>

Kill by PID code

Run

$ sudo kill -9 <PID>

Sign Meanings

#0    SIGNULL   Null	Check access to pid
#1    SIGHUP    Hangup	Terminate; can be trapped
#2    SIGINT    Interrupt   Terminate; can be trapped
#3    SIGQUIT   Quit        Terminate with core dump; can be trapped
#9    SIGKILL   Kill        Forced termination; cannot be trapped
#15   SIGTERM   Terminate   Terminate; can be trapped
#24   SIGSTOP   Stop        Pause the process; cannot be trapped. This is default if signal not provided to kill command.
#25   SIGTSTP   Terminal    Stop/pause the process; can be trapped
#26   SIGCONT   Continue    Run a stopped process

Select a Binary Version

$ sudo update-alternatives --config <launcher>

Creating

  • Create file ~/.bash_aliases, and insert alias 'alias_name'='original shell command'

Obs.: There can’t be spaces between the equal character.

Setting a wireless Gamepad

Xbox driver

sudo apt install -y xboxdrv

Installing the AntiMicro (a graphical app to map a keyboard and mouse controls for a gamepad) via PPA

$ sudo add-apt-repository ppa:mdeguzis/libregeek
$ sudo apt update
$ sudo apt install -y antimicro

See more

Installing the JTest (a gamepad calibrator)

$ sudo apt install -y jstest-gtk

See more

# copie a pasta que contém todo o projeto para /opt. Ou crie uma pasta em /opt, a qual deverá guardar o arquivo binário
# create
$ sudo mkdir /opt/<folder>
$ sudo mkdir /opt/<folder>/<version>
# copy
$ sudo cp -R <binary_or_folder_with_the_binary> /opt/<folder>/<version>
# cria um link simbólico para o arquivo binário ou script, guardado em /opt, em /usr/bin.
$ sudo sudo ln -s /opt/<folder>/<version>/<binary_file> /usr/bin/<symbolic_link_name>-<version>
# Obs.: ao executar $ ls /usr/bin/<symbolic_link_name>-<version> este deve aparecer em azul claro, caso contrário o caminho
# foi setado incorretamente. Para conhecimento, as cores e os seus significados, são: verde claro: arquivo binário;
# azul: pasta; vermelho: arquivo com algum tipo de problema; azul claro: atalho; dentre outros.
# cria um shortcut(atalho) para aparecer na busca do sistema. Este poderá conter uma imagem que aparecerá na busca
# Geralmente o sistema busca tanto pelo nome, quanto pelo shortcut name
$ sudo touch /usr/share/applications/<shortcut-name>-<version>.desktop
# Edite o conteúdo com as informações abaixo do comando:
$ sudo gedit /usr/share/applications/<shortcut-name>-<version>.desktop
[Desktop Entry]
Type=Application
Exec=/opt/... %F
Name=<Application Name>
Icon=/opt/<folder>/<icon_path>.ico

Installation

Run

$ sudo apt-get install -y winff

Change Bluetooth Label

  • To know the MAC address of your bluetooth driver, run

    $ ls /var/lib/bluetooth/
    
  • So run

    $ sudo gedit /var/lib/bluetooth/<mac_address>/config
    
  • Beside "name" change to the desired value, close and save the document

  • Restart the adapter

    $ sudo service bluetooth restart
    
############ Mudando o nome do PC
# Execute no terminal
$ sudo gedit /etc/hostname
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment