Skip to content

mehrabtpc/shetabit-ubuntu-practical

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 

Repository files navigation

ubuntu-practical

Practical Ubuntu linux commands

Update and Upgrade

sudo apt update

sudo apt upgarde

Auto remove and clean

sudo apt autoremove
//or
sudo apt auto-remove

sudo apt autoclean
//or
sudo apt auto-clean

Install and Remove programs

//install
sudo apt install app_name

//remove
sudo apt remove app_name

//remove completely
sudo apt remove --purge app_name

Install and Remove deb packages

//install
sudo dpkg -i /path/to/package.deb

//remove
sudo dpkg -r /path/to/package.deb

Create symlink

ln -s /path/to/file /path/to/link_name

//example in laravel
ln -s /var/www/html/laravel/storage/app/public /var/www/html/laravel/public/storage

//unlink to remove the link and not where it is pointing at
unlink /path/to/link_name

Alias commands in termeinal

sudo nano ~/.bashrc
//add your alias
alias alias_name = "original command"
//example
alias art = "php artisan"
alias gp = "git push origin master"

source ~/.bashrc

Repository update error

Problem:
E: The repository 'http://ppa.launchpad.net/armagetronad-dev/ppa/ubuntu bionic Release' does not have a Release file. 
N: Updating from such a repository can't be done securely, and is therefore disabled by default. 
N: See apt-secure(8) manpage for repository creation and user configuration details.

Solve:
sudo apt-add-repository -r ppa:armagetronad-dev/ppa
sudo apt update -q

Reload network-manager

sudo systemctl restart network-manager.service

Upload and Download to server via SSH

//upload
scp [source file] [username]@[destination server]

//download
scp [username]@[destination server]:[local path]

//example
scp -P 3031 /home/projects/project.zip [email protected]:/var/www/html

scp -P 3031 [email protected]:/var/www/storage/app/Laravel/2018-04-25-20-45-22.zip /home/hashem/

Transfer file/directories with rsync

//simple file
rsync /home/simple.txt [email protected]:/home

//with directory
rsync -rt /home/transfer_me [email protected]:/home

Set cronjob

sudo apt-get update
sudo apt-get install cron

crontab -e
//add your command
* * * * * /usr/bin/php /var/www/domain.com/backup.php > /dev/null 2>&1

Unzip zip files

sudo apt-get install unzip

unzip file.zip -d destination_folder

Config www directory www-data user in LAMP

sudo adduser username www-data
sudo chown -R username:www-data /var/www/html

//enable mod_rewrite
sudo a2enmod rewrite

sudo nano /etc/apache2/sites-available/000-default.conf
//append end of file
<Directory /var/www/html>
    Options Indexes FollowSymLinks
    AllowOverride All
    Require all granted
</Directory>

//restart apache
sudo systemctl restart apache2

Apache VirtualHost

sudo nano /etc/apache2/sites-available/000-default.conf

//Append and save:
<VirtualHost *:80>
  ServerName myapp.dev
  DocumentRoot "/var/www/html/myapp/public"
  <Directory "/var/www/html/myapp/public">
    AllowOverride all
  </Directory>
</VirtualHost>

sudo nano /etc/hosts
//Add 
127.0.0.1 myapp.dev

sudo service apache2 restart

Laravel storage permissions

sudo chown -R $USER:www-data storage
chmod -R 775 storage

Laravel Installer

composer global require laravel/installer

sudo nano .bashrc
//append
export PATH="$HOME/.composer/vendor/bin:$PATH"

Install openconnect

sudo apt-get update
sudo /sbin/modprobe tun
sudo apt-get install openconnect
sudo openconnect SERVER_ADDRESS

Switch php version

sudo update-alternatives --config php

//disable current php version
sudo a2dismod php8.1

//enable new php version
sudo a2enmod php8.0

sudo systemctl restart apache2

Export & Import large database

//export
mysqldump -u username -p database_name > data-dump.sql

//import
mysql -u username -p new_database < data-dump.sql

SSH connection error

//WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!

ssh-keygen -R <server_ip>

Increase PHP Memory Limits

//Edit the PHP.ini File

memory_limit = 256M
upload_max_filesize = 12M
post_max_size = 13M
file_uploads = On
max_execution_time = 180

About

Practical Ubuntu linux commands

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published