2 2
NicoD

tutorial My most useful Linux terminal commands for Ubuntu/Debian

Recommended Posts

Hi all. For a new video I've made a list with my most used/useful terminal commands.
Please let me know what I've missed, or which commands you use most.
 

Useful Linux commands for Ubuntu/Debian
---------------------------------------
Update/Install
--------------
sudo apt update                               Update repolists
sudo apt upgrade                              Upgrade system/programs
sudo apt autoremove                           Remove obsolete programs
sudo apt install programName                  Install program
sudo apt remove programName                   Remove program 
sudo aptitude install                         When having issue's with apt, aptitude can help to solve this
sudo apt update && sudo apt upgrade           Update and upgrade together/You can run multiple commands with &&
sudo dpkg -i packageName.deb                  Install .deb file

Root user
---------
sudo passwd                                   Change root password
su                                            Super User/Enter root user

Debug/Monitor
-------------
dmesg                                         Shows debug messages 
uname -a                                      Shows basic system information
env                                           Shows the environment information
htop                                          Hardware monitor

Switch terminal
---------------
ctrl + ALT + F4       (F1 - F6)                                    Open new terminal 4
ctrl + ALT + F1                                                    Go back to terminal 1
ctrl + ALT + F7                                                    Go back to desktop 

Reboot/Shutdown
---------------
sudo reboot                                   Reboot
sudo shutdown now                             Shutdown

CPU Tools
---------
taskset -c 3 programName                      Use a specific core for an application   
lscpu | grep MHz                              Show cpu frequency    
cpufreq-set -g performance                    Set governor to performance
cpufreq-set -u 2Ghz                           Set max frequency for all cores
cpufreq-set -c 0-1 -u 1.8Ghz                  Set max frequency for specific cores

Files/Directories
-----------------
nano /home/fileToRemove.txt                   Create a txt file with Nano. You could use any other texteditor.
cat /home/fileToRemove.txt                    Shows the content of a file
cp /home/fileToRemove.txt /home/copy.txt      Copy file
find /home/ -iname "*.txt"                    Search files that end with .txt
comm /home/fileToRemove.txt /home/copy.txt    Compare files
rm /home/fileToRemove.txt                     Remove file
mv /home/copy.txt ~/Documents/                Move file
mkdir /home/directoryToGoTo/                  Create directory
cd /home/directoryToGoTo/                     Go to directory
ls                                            List directory
cd ..                                         Go to the above directory
rmdir /home/directoryToGoTo/                  Remove directory                             
wget http://www.website.com/file.txt          Download file

Zip/Tar/GunZip
--------------
zip myzip file1 file2 file3                   Create zip file
unzip myzip.zip                               Unzip file
tar xvf filename.tar                          
gunzip filename_tar.gz

Mount drives/USB Devices
------------
lsusb                                         List USB devices
lsblb                                         List attached drives
mount /mount/mountedDisk /dev/sda2            Mount drive
sudo chmod -R 777 /mount/mountedDisk          Give user read/write permissions
df -a                                         List all filesystems

Swap file/ZRam
--------------
sudo apt install zram-config                  Install zram script

sudo fallocate -l 8G /swapfile                Allocate 8GB for swapfile
sudo chmod 600 /swapfile                      Give the correct rights for the swapfile
sudo mkswap /swapfile                         Make it a swapfile
sudo swapon /swapfile                         Turn on the swapfile
sudo nano /etc/fstab                          Open fstab and add the line ...
  |_
       /swapfile swap swap defaults 0 0


Wifi
----
sudo nano /etc/network/interfaces 

and write:
 auto wlan0
 iface wlan0 inet dhcp 
                wpa-ssid {ssid}
                wpa-psk  {password}
				
				OR
				
nmcli device wifi rescan                                           Scan for available wifi networks
nmcli device wifi list                                             Show available wifi networks
nmcli device wifi connect SSID-Name password wireless-password	   Connect wifi

ip a                                                               Show ip
ifconfig                                                        
iwconfig

Change Keyboard Layout
----------------------
sudo dpkg-reconfigure keyboard-configuration                       Set keyboard layout

Others
------
reset                                                              Clear terminal 
shift + page up                                                    Scroll up
shift + page down                                                  Scroll down 
tab                                                                Autocomplete
ctrl + c                                                           Quit for many programs 
date                                                               Show date/time

Armbian
-------
sudo armbianmonitor -m                                             
sudo armbian-config

Made by NicoD 	

 

Share this post


Link to post
Share on other sites

Pimp your bash. To be fair I copied some from the link at the bottom:

 

A few commands are needed quite often and to reduce typing a little bit, voila:

To create the file  nano ~/.bash_aliases


############################
# my personal Aliases list #
############################
# to create the file  nano ~/.bash_aliases


# **** DIRECTORY LISTING in human-readable units ****
alias ll="ls -lhAF"
alias ..="cd .."
alias ...="cd ../../../"
alias back="cd $OLDPWD"

alias lsmount="mount |column -t"


# * Disk Space Usage in human-readable units,  including filesystem type *
alias dfh="df -Tha --total"

alias df="df -h --exclude=squashfs"


# * ALL files in a directory listed,  according their size *
alias du="du -ach | sort -h"


# * listing process table in detail *
alias psa="ps auxf"

alias dmesg="dmesg --human"


# * How to really CLEAR the terminal *
alias clr='printf "\033c"'

alias h="history"



# reload bash config
alias reload="source ~/.bashrc"
Now execute  . ~/.bashrc  in your terminal (there should be a space between the . and ~/.bashrc )

 

https://pastebin.com/kzPjE8y4    |   http://smlr.us/

 

Share this post


Link to post
Share on other sites

Here's the first video.
Update/Upgrade/Install software.
Change passwords/enter root account.
Some debug tools.
How to switch terminals, and how to reboot and shutdown the system.

 

Share this post


Link to post
Share on other sites

Looks good! Only thing missing for my linux noobs is a simple tar overview for extracting and creating archives and a simple grep overview

 

Can I win the hat this time please?

Share this post


Link to post
Share on other sites
37 minutes ago, qstaq said:

Looks good! Only thing missing for my linux noobs is a simple tar overview for extracting and creating archives and a simple grep overview

Thank you. That's indeed missing. I'll add it for the next video.

 

38 minutes ago, qstaq said:

Can I win the hat this time please?

I still haven't found a hat sponsor. Sorry :)
 

Share this post


Link to post
Share on other sites
2 2