maanantai 14. lokakuuta 2013

Usefull commands (Personal note)

Create a file.txt file which tells you every service installed on your computer.
sudo service --status-all >> file.txt

Check Linux information:
lsb_release -a

List all users on your computer
awk -F: '$6 ~ /\/home/ && $3 >= 500 {print $1}' /etc/passwd

Create python file that can be run from anywhere (helloworld.py)
#!/usr/bin/env python
print "Hello, World!"
Give chmod 755 to the helloworld file and try running it from somewhere. Or execute chmod +x helloworld.py

List file permissions
ls -l

Change file owner
sudo chown seppo hellurei.py 

Change your password
passwd

Protect your file from others
chmod og-rwx users.txt

List password hash
sudo cat /etc/shadow

Commands for Firewall
ufw enable – turn on the firewall
ufw disable – turn off the firewall
ufw default allow – allow all connections by default
ufw default deny – drop all connections by default
ufw status – current rules and
ufw allow port – to allow traffic on port
ufw deny port – port block
ufw deny from ip – ip block

Commands for Package Manager.
apt-get update – refresh updates available
apt-get upgrade – update all packages
apt-get dist-upgrade – version update
apt-get install pkg – installing pkg
apt-get remove pkg – uninstall pkg
apt-get autoremove – removing packages obsotletos
apt-get -f install – try to fix packages
dpkg –configure -a – try to fix a broken package
dpkg -i pkg.deb – install file pkg.deb
(file) /etc/apt/sources.list – list of repositories APT

See all open ports for your machine
netstat -anltp | grep "LISTEN" 

Start web server serving current directory tree at http://localhost:8000/ (No admin rights needed)
python -m SimpleHTTPServer


Giving root access 
either this one
 sudo adduser vogella admin 
or this one should work
 sudo adduser vogella sudo

Set up backup with timing command
sudo crontab -e

Disable screensaver
xset s 0 0 (times in seconds, 0 means off) and you can turn power management off by command: xset -dpms and on by xset +dpms

How to use grep: ls -l|grep mystatus.sh 

Ei kommentteja:

Lähetä kommentti