This file contains useful Linux commands and procedures that can help you navigate and manage your system effectively. Whether you're looking to change file permissions, manage users, work with SSH, or handle Git repositories, this guide has you covered.
General Linux (BASH) Commands:
Change permissions of a file:
chmod NNN dir/file1
or
chmod -R NNN file (for recursive changes)
Get IP address:
ip addr show
Users/Accounts:
Login as `www-data`:
sudo -u www-data bash
Execute a command as another user (e.g., `www-data`):
sudo -u www-data git pull
or
sudo -u www-data ./easymap -n pn -w ins -sim -r mini_chr1 [...]
Secure Shell (SSH):
Install the server program on the computer you want to use as a server:
sudo apt-get install openssh-server
Install the client program on the computer you want to use as a client:
sudo apt-get install openssh-client
Connect to the server from the client machine:
ssh username@address
(e.g., `$ ssh umh@10.1.28.51`)
Start Dropbox:
.dropbox-dist/dropboxd
How to Erase Hidden Trash:
Find all places where Ubuntu stores trash:
sudo find / -type d -name *Trash*
In the example case:
/home/dws/.local/share/Trash
Delete all files in the expunged directory:
sudo rm -rf ~/.local/share/Trash/expunged/*
GIT:
Install Git:
sudo apt-get install git
Set Git account on a local machine:
git config --global user.name "davidwilson-85"
and
git config --global user.email "dws1985@hotmail.com"
Initialize a Git repository:
git init
Add files to the staging area:
git add testfile.txt
or
git add -A (to add all files with changes and untracked files)
Commit and send changes to the repository:
git commit -m "Just a test commit"
and
git push -u origin master
Apache and PHP Installation:
Update repository: `$ sudo apt-get update`
Install Apache: `$ sudo apt-get install apache2`
Install PHP including components for Apache: `$ sudo apt-get install php libapache2-mod-php`
Restart Apache: `$ sudo service apache2 restart`
How to Create an Amazon Ubuntu Instance:
- Go to Amazon AWS dashboard > EC2
- Create a new instance (Ubuntu 16 free tier t2.micro) and follow the wizard
- Activate necessary security groups to allow access through HTTP
Conclusion:
These Linux commands and procedures are essential for managing your system effectively. Whether you're a beginner or an experienced user, these tips can help you navigate and control your Linux environment with ease.