Some random linux commands

List running processes: ps aux

Enable network interface: ifup eth0 (the first interface, lan, is eth0, and goes on with eth1 etc)

To make the ethernet interface to autostart on boot, in /etc/sysconfig/network-scripts/ifcfg-eth0 make sure that ONBOOT=yes

Mound CD/DVD drive: mount /dev/cdrom /mnt

Edit a file using text editor: vi /path/to/file
Press ESC and then type :w and hit Enter to exit discarding changes
Press ESC and then type q! and hit Enter to exit saving changes

Install a program using yum: yum install httpd (httpd is Apache)

Restart a service: service httpd restart

View the firewall rules:  cat /etc/sysconfig/iptables

Add a firewall rule: (this example enables port 80) iptables -I INPUT -m state –state NEW -m tcp -p tcp –dport 80 -j ACCEPT
After the change you need to save and restart the iptables:
service iptables save
service iptables restart

Create a user:
useradd uddika
passwd uddika

Give sudo access:
sudo adduser <username> sudo

static IP: http://www.cyberciti.biz/faq/linux-configure-a-static-ip-address-tutorial/

DNS: http://www.unixmen.com/dns-server-installation-step-by-step-using-centos-6-3/

Connect to mysql: mysql -u root -p

To auto start a new service:

  • Find out the name of service’s script from /etc/init.d/ directory e.g. mysqld or httpd
  • Add it to chkconfig
    sudo /sbin/chkconfig --add mysqld
  • Make sure it is in the chkconfig.
    sudo /sbin/chkconfig --list mysqld
  • Set it to autostart
    sudo /sbin/chkconfig mysqld on

To stop a service from auto starting on boot

  • sudo /sbin/chkconfig mysqld off

live log view: tail -f logfile

Samba (windows share): yum install samba3-client

mount.cifs //SERVER_ADDRESS/SHARE_NAME MOUNT_POINT -o user=USERNAME
mount.cifs //192.168.10.118/Downloads /mnt -o user=share,pass=password
umount -l

Share

Leave a Reply

Your email address will not be published. Required fields are marked *

five − five =