/linux-commands

A cheat sheet for Linux commands

Linux Commands Cheat Sheet

A cheat sheet for Linux commands, and how to install some packages and drivers.

Basic Commands:

Find out your user name:

whoami

Get full path to current directory:

pwd

List files in current directory:

ls

List all files AND their respective attributes:

ls -l@

Hidden files start with a period ("."). List all files and hidden files:

ls -a

Clear terminal screen:

clear

Go back one directory level:

cd ..

Delete a file:

sudo rm /path/to/file/some-file.txt

Delete a directory AND ALL ITS CONTENTS (BE CAREFUL WITH THIS ONE):

sudo rm -rf /path/to/directory

Remove a directory:

rmdir /path/to/some/dir

Create a new file:

touch /path/to/some/directory/new-file.py
# OR this for new file in 'pwd':
touch new-file.txt

Locate a file (Linux only):

locate some-file-name

MOVE a file or folder using "mv":

sudo mv /path/to/file/some-file.txt /new/path/location

ALSO use "mv" to RENAME a file:

sudo mv old-file-name.txt new-file-name.txt

View the "manual" for any command:

man {SOME_COMMAND}
# for example: man history
# Press CTRL+Z to exit

Enter Python Interpreter:

python3
# ..or for Python v2.x
python
# Press CTRL+Z to exit

"History" Command and Grep to find specific command you did before:

history | grep {SOME_KEYWORD}

Kill Processes:

ps aux | grep -i apt
sudo kill -9 <process id>

Unzip Tar Archives:

tar xzf file.tar.gz
tar xjf file.tar.bz2
tar xzvf file.tar.gz

### Tweak CPU on Linux
```bash
sudo apt install aptitude
sudo aptitude install cpufrequtils
sudo cpufreq-set -f 2000
indicator-cpufreq
for x in /sys/devices/system/cpu/*/cpufreq/; do echo 800000 | sudo tee $x/scaling_min_freq; done
cpufreq-info
sudo cpufreq-set -f `cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq`

Install Snap Package Manager

sudo apt update
sudo apt upgrade -y
sudo apt install snapd
sudo apt purge snapd
sudo apt install snapd
snap find "program name"
sudo snap install {PROGRAM}

Install PHP 7.3

https://thishosting.rocks/install-php-on-ubuntu/

Install Lua 5.3 on Linux Debian

mkdir lua_build
cd lua_build
wget http://www.lua.org/ftp/lua-5.3.4.tar.gz
sudo tar -zxf lua-5.3.4.tar.gz
cd lua-5.3.4
sudo make linux test
sudo make install

Install the LÖVE 2D Game Engine for Lua

sudo add-apt-repository ppa:bartbes/love-stable
sudo apt-get update

or

sudo apt install love

Python and Lua Links:

Install GO Language v1.12

https://golang.org/dl/

sudo wget https://dl.google.com/go/go1.12.1.linux-amd64.tar.gz
sudo tar -xvf go1.12.1.linux-amd64.tar.gz
sudo mv go /usr/local
export GOROOT=/usr/local/go
export GOPATH=/home/benji/Desktop/repos/GoProject
export PATH=$GOPATH/bin:$GOROOT/bin:$PATH

Create Bootable Linux USB ON Linux:

Ask Ubuntu - Create a live USB

Startup Disk Creator Method

sudo apt-get install usb-creator-gtk

UNETBOOTIN Method:

sudo add-apt-repository ppa:gezakovacs/ppa
sudo apt-get update
sudo apt-get install unetbootin

Restart Apache Server localhost

/etc/init.d/apache2 restart
# or
sudo /etc/init.d/apache2 restart

Disable Touchpad

xinput set-prop <id> "Device Enabled" 0

Install Aptitude:

sudo apt install aptitude
sudo aptitude install cpufrequtils

Install Firefox

sudo apt-get install firefox

Install Chrome

wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
sudo dpkg -i google-chrome*.deb

Configure Pantheron/Gnome Desktop Settings:

gsettings set org.pantheon.files.preferences single-click false
gsettings set org.gnome.desktop.interface text-scaling-factor 1.2
gsettings set org.pantheon.terminal.settings unsafe-paste-alert false
gsettings set org.gnome.desktop.notifications show-banners false

Fix Bad Installation of Skype

  • Uninstall Skype:
sudo service bluetooth restartSKYPE
sudo apt remove skype
sudo apt remove skypeforlinux.

Install cURL Library:

sudo apt install apt-transport-https curl

Reinstall Skype

curl https://repo.skype.com/data/SKYPE-GPG-KEY | sudo apt-key add -
echo "deb [arch=amd64] https://repo.skype.com/deb stable main" | sudo tee /etc/apt/sources.list.d/skype-stable.list.
sudo apt update
sudo apt install skypeforlinux

Ask Ubuntu - Fix Bluetooth Issues

sudo service bluetooth restart
<cite>"I've edited the `/etc/bluetooth/audio.conf` file: `sudo -H gedit /etc/bluetooth/audio.conf` and add this line in the end of it: Disable=Headset. Users on Ubuntu 17.04 and above may not have `audio.conf`, but can instead use `main.conf`."</cite>

__PEEK:__
```bash
sudo add-apt-repository ppa:alexlarsson/flatpak
sudo apt update
sudo apt install flatpak
flatpak install --user https://flathub.org/repo/appstream/com.uploadedlobster.peek.flatpakref
flatpak run com.uploadedlobster.peek
flatpak update --user com.uploadedlobster.peek
https://github.com/phw/peek

UNLOCK READ-ONLY SDCARD or USB

Ask Ubuntu - SDB Read Write

sudo hdparm -r0 /dev/

FAT32 Format using Terminal

Use fdisk to find all drives:

sudo fdisk -l

Or use df to show volumes:

df

The drive will be: /dev/sdb{X}

sudo umount /dev/sdb{X}

Un-mount the drive:

sudo mkfs.vfat -n 'LINUX_BOOT' -I /dev/sdb{X}
# ..or
sudo mkfs.vfat -I /dev/sdb{X}

Format the drive as FAT32:

ls -1 /dev > ~/before.txt
ls -1 /dev > ~/after.txt
diff ~/before.txt ~/after.txt

INSTALL EXFAT UBUNTU

sudo apt install exfat-fuse exfat-utils

SLOW DOWN CPU

for x in /sys/devices/system/cpu/*/cpufreq/; do echo 1200000 | sudo tee $x/scaling_max_freq; done
sudo apt install aptitude
sudo aptitude install cpufrequtils

INSTALL ATOM IDE ON UBUNTU 18

Atom IDE Menu Font Not-Visible

wget -O atom-amd64.deb https://atom.io/download/deb

INSTALL ATOM IDE ON LINUX MINT

sudo add-apt-repository ppa:webupd8team/atom
sudo apt update
sudo apt install atom

INSTALL ZOOM

wget -c https://zoom.us/client/latest/zoom_amd64.deb
sudo apt-get install libxcb-xtest0
sudo dpkg -i zoom_amd64.deb

Install Chromium

sudo apt install chromium-browser

Install Linux Wireless Drivers for Macbook Pro

Hardware Support:

"BROADCOM 4360 comes with two different chips: 14E4:4360 NOT SUPPORTED and 14E4:43A0 SUPPORTED" Check for hardware support:

lspci -vnn | grep -i net

Install Linux wireless drivers on a Macbook:

sudo apt-get update
sudo apt-get install linux-headers-$(uname -r|sed 's,[^-]*-[^-]*-,,') broadcom-sta-dkms
OR:
sudo apt-get install --print-uris linux-headers-$(uname -r|sed 's,[^-]*-[^-]*-,,') broadcom-sta-dkms
sudo modprobe -r b44 b43 b43legacy ssb brcmsmac
modprobe wl

YouTube video explanation Apple MD212LL/A (Late-2012)

Install MacBook Fan Control:

sudo nano /etc/mbpfan.conf

FIX CORRUPTED SD or USB:

sudo fsck /dev/sdc1