This page has some quick tips for getting things done on Linux. These commands should work on Ubuntu, Mint and Raspbian.
Some commands require root permissions. To run a command as root add sudo to begining of command.
Swith to another user call Fred:
su Fred
To see how long the system has been running:
uptime
To see the last time the system was shut down:
sudo last -x shutdown
To exit the session:
exit
To shut down the system imediately:
sudo shutdown now
To shut down and power off the system in two minutes:
sudo shutdown -h +2
The '-h' switch tells the system to also power off if the option is available.>/p>
To send a message to other users and shut down in 3 minutes:
sudo shutdown -h +3 "It's Going Down!!!"
Another option is:
sudo poweroff
To cancel a shutdown:
sudo shutdown -c
To reboot the system:
sudo reboot
To update your list of available packages: sudo apt-get update
To upgrade your packages: sudo apt-get upgrade
To remove old packages:sudo apt-get autoremove
To view full time, date and timezone: date
To change timezone: sudo dpkg-reconfigure tzdata
An ancient looking GUI window will appear. Use the arrow keys to select your timezone and press Enter
The chown command changes the owner and group for one or many files or folders.
Change the ownership of a file called example.txt to the user YourName and the group YourGroup:
sudo chown YourName:YourGroup example.txt
The chmod command changes the permissions and attributes for a file.
To change the permissions for example.txt to read for write for owner, read for group and no acces for any other users:
sudo chmod 640 example.txt
To make a file called example.sh executable:
chmod +x example.sh
You can use grep to filter the output from commands.
For example, if you are using the ls command look for a .txt file in a large folder:
ls | grep .txt
Another example, get the process ID for any python scripts running on the system:
ps aux | grep python
Note that grep will always display an entry your actual grep request in the results.
You can use the head and tail command to see the first or last line of text in a file.
To see the first five lines in a file called example.txt:
head -5 example.txt
To see the last ten lines in a file called example.txt:
tail -10 example.txt
To view all running processes and their PIDs:
ps aux
To view an active list of running processes:
top
To kill a running process with a PID of 2575:
sudo kill 2575
Samba is a program that shares files and folders with Windows networks
To install Samba:
sudo apt-get install samba-common-bin
Main config file:
/etc/samba/smb.conf
To add user to Samba:
sudo smbpasswd -a username
To start Samba server:
sudo /etc/init.d/samba start
To stop Samba server:
sudo /etc/init.d/samba stop
To restart Samba server:
sudo /etc/init.d/samba restart
To install Apache2:
sudo apt-get install apache2
Main config file: /etc/apache2/apache2.conf
Default document root: /var/www
Log files: /var/log/apache2
sudo /etc/init.d/apache2 start
sudo /etc/init.d/apache2 stop
sudo /etc/init.d/apache2 restart
SSH is a way to access a remote computer from the terminal. it is commonly used to administer servers.
To install SSH server:
sudo apt-get install openssh-server
To install SSH client:
sudo apt-get install openssh-server
To connect to the remote computer: ssh username@computername or ssh username@IP address
To stop the SSH server:
sudo /etc/init.d/ssh stop
To start the SSH server:
sudo /etc/init.d/ssh start
To restart the SSH server:
sudo /etc/init.d/ssh restart
The configuration file is in /etc/ssh/sshd_config
Cheers
Anth
_____________________________________________