Difference between revisions of "Ubuntu console notes"

From Vague Hope Wiki
Jump to: navigation, search
(SVN)
Line 285: Line 285:
  
  
 +
== Security ==
 +
* Change default home dir permissions to 700
 +
<pre>
 +
sudo vi /etc/login.defs
 +
UMASK          0077
 +
</pre>
  
  
 
[[Category:dev]]
 
[[Category:dev]]

Revision as of 02:44, 17 May 2011

GENERAL

notes: to put " " in a command, it must be escaped, "\ " to do 2 commands, seperate with " && "

list something: ls

FILES and FOLDERS

these are easy: cd pwd(Print Working Directory) mkdir cp (copy), mv (move / rename), rm (remove) (remove directory with subitems: "rm -rf") ls -lah (list symbolic links) du (measure file/folder size) df (free space) ("df ." shows partition with current dir)

copy new files: rsync -rtP /media/a/a /media/b/ (recursive, preserve time stamps, partial and progress)

permissions: chmod - change rights chown - change ownership chgrp - change group

root: "sudo -i"

USERS

list all users: cat /etc/passwd | cut -d ":" -f1

change password: passwd

make a user: sudo useradd <username> sudo useradd -d /home/<username> -m <username> sudo passwd <username>

groups: sudo groupadd subversion //sudo useradd -G subversion haku sudo usermod -a -G subversion haku

show groups: $ groups

HARDWARE

list drives: sudo lshw -short -C disk

list devices: lspci

free mem: free

HDD

mount: "sudo mount /dev/sda1 /mnt" (sda1 may be a usb / sata / scsi) (make perminant by using "sudo nano /etc/fstab" umount: "sudo umount /mnt" or "sudo umount /dev/hda1" (can point at either device or mount point) eject: "sudo eject /dev/hdc" (note the lack of a number - eject the volume, not the partition) ( $ ls /dev/sd* )

new: find: sudo lshw -C disk partition: sudo fdisk /dev/sdc format: sudo mke2fs -j /dev/sdc1

PROCESSES

list active processes: ps aux

LOGS

read with less

TIME

ntpdate rdate nano /etc/ntp.conf

CONFIGURE SOMETHING

dpkg-reconfigure xserver-xorg

NETWORKING

list network connections: sudo ifconfig

status: netstat netstat -ant (t = tcp) netstat -anu (u = udp)

list open ports again process id: sudo netstat -lpn

edit net config: sudo nano /etc/network/interfaces

dns servers: sudo nano /etc/resolv.conf

restarting networking: sudo /etc/init.d/networking restart

wifi.config: iwconfig

wifi.scan for wifi access points: iwlist scan

wifi config code to go in /etc/network/interfaces note: AuthMode can be "WEPAUTO", "OPEN", "SHARED", "WPAPSK", "WPA2PSK", "WPANONE" note: EncrypType can be "NONE", "WEP", "TKIP", "AES" auto ra0 iface ra0 inet dhcp pre-up iwpriv ra0 set AuthMode=WPAPSK pre-up iwpriv ra0 set EncrypType=TKIP pre-up iwconfig ra0 essid my_essid pre-up iwpriv ra0 set WPAPSK="my_pass_key"

FTP

start ftp server: sudo /etc/init.d/proftpd [start/stop/restart]

check conf: sudo proftpd -td5

SSH

SSHd config file: sudo nano /etc/ssh/sshd_config

SSHd restart: sudo /etc/init.d/ssh restart

RSYNC

commands: sudo nano /etc/default/rsync (change "RSYNC_ENABLE=true") sudo nano /etc/rsyncd.conf sudo nano /etc/rsyncd.secrets sudo /etc/init.d/rsync restart

SAMBA

mount: sudo mount -t cifs //192.168.0.42/qnap0 -o username=admin,password=password /media/pc5_qnap0/

SCREEN

general crtl+a, " (window list) ctrl+a, # (replace # with a number to switch to screen #) ctrl+a, c (create a screen) screen -ls (list detatched windows) screen -r [screen name] (re-attach a screen)

SERVICES / DAEMON MANAGEMENT

install manager: # sudo aptitude install sysvconfig

access manager: # sudo sysvconfig

lm-sensors

general sensors nano /etc/sensors.conf man sensors.conf (press q to exit)

HDDTEMP

sudo hddtemp /dev/hd

IPTABLES

show tables sudo iptables -L

save file /etc/iptables.up.rules

write / restore iptables-save / iptables-restore

BLUETOOTH

send file: $ gnome-obex-send

GNOME

config: $ gconf-editor

change window manager $ metacity --replace

POWER

suspend: $ sudo s2ram [--force] hibernate: $ sudo s2disk

SERVICES

configure startup services (may need putty): rcconf

MOBLOCK

general: sudo moblock-control start sudo moblock-control stop sudo moblock-control restart sudo moblock-control reload sudo moblock-control update sudo moblock-control status sudo moblock-control test

logs: tail -f /var/log/moblock.log

config file: /etc/moblock/moblock.conf

To whitelist IPs, edit the following part: # Do a "moblock-control restart" when you have changed these settings. WHITE_IP_IN="" WHITE_IP_OUT="" WHITE_IP_FORWARD=""

Insert e.g. "192.168.178.1" to whitelist a single IP, or e.g. "192.168.178.0/24" to whitelist an IP range (192.168.178.0 - 192.168.178.255) or e.g. "192.168.0.0/16" to whitelist a bigger IP range (192.168.0.0 - 192.168.255.255) Separate IP addresses with a whitespace.

WEBCAM

$ vgrabbj -d /dev/video0 -f cap000.jpg -i vga $ gqcam -v /dev/video0 -d cap000jpg

SVN

create new project:

	$ sudo mkdir myproject
	$ sudo chown -R www-data:subversion myproject
	$ sudo chmod -R g+rws myproject
	$ sudo svnadmin create /home/svn/myproject
	$ sudo chmod -R g+rws myproject

user management: add first user:

	$ sudo htpasswd -c /etc/subversion/passwd user_name

and more users / change passwd:

	$ sudo htpasswd /etc/subversion/passwd second_user_name

VNC

$ vncviewer -bgr233 -encodings "tight copyrect" localhost:15901


Fonts

Put fonts in /usr/share/fonts

Update font cache with:

sudo fc-cache -f -v


Security

  • Change default home dir permissions to 700
sudo vi /etc/login.defs
UMASK           0077