LINUX Notes
- cp: omitting directory
- Create symbolic links
- Test disk performance with hdparm
- Install from source
- Install .bin
- RPM installation
- Find USB devices
- Mount USB storage devices
- Static IP configuration for Linux
- Install default LAMP stack (Ubuntu) using apt-get
- Network interface disappeared after moving VMware virtual machine
- Update and patch CentOS / Redhat
- Show list of software to be updated
- Some packages are being held back
- Basic IPTables configuration
- Only update specific packages
- Configure SELinux to be permissive
tail -f /var/log/messages
ls -lh
cp: omitting directory
Problem: when trying to copy a directory to another location I get the following error cp: omitting directory.
Solution: add -r after the command cp, which means copy directories recursively.
cp -r old_file new_file
Create symbolic links
ln -s /etc/apache2 /home/user
* Directories must use soft links.
Test disk performanance
hdparm -Tt /dev/sda
Install from source
Untar
tar zxvf file.tar.gz
Move to the newly created directory.
cd file
Execute the script.
./file.sh
Install .bin
Change permission.
chmod +x file.bin
Execute the script.
./file.bin
RPM installation
Install RPM package.
rpm -iuh packages
Upgrade RPM package.
rpm -uvh package
Find USB devices
lsusb
Mount USB storage devices
The USB drive will be mount in to the folder named “mount” located in the users home directory.
mount /dev/usb mount
Assign the mount directory proper permission.
chmod 777 /mount/point
Unmount the USB device.
umount /dev/usb
Static IP configuration for Linux
The configuration is located at /etc/network/interfaces.
# The primary network interface # allow-hotplug eth0 auto eth0 iface eth0 inet static address 192.168.1.3 network 192.168.1.0 netmask 255.255.255.0 broadcast 192.168.1.255 gateway 192.168.1.1
Set DNS to resolve /etc/resolv.conf.
nameserver 192.168.1.1
Install default LAMP stack (Ubuntu) using apt-get
apt-get install apache2 php5-mysql libapache2-mod-php5 mysql-server
Network interface disappeared after moving VMware virtual machine
The solution is to remove the persistent-net.rules.
In Debian the file has the name of :
rm /etc/udev/rules.d/z25_persistent-net.rules
On Ubuntu the file name changes to :
rm /etc/udev/rules.d/70-persistent-net.rules
Then reboot.
Update and patch CentOS / Redhat
To update CentOS or Redhat issue the following command with Root privileges.
yum update
The output will be
Show list of software to be updated
yum list updates
Some packages are being held back
Run
apt-get dist-upgrade
Basic IPTables configuration
The following allows port 22, 80 and 443 in.
*filter # Allows all loopback (lo0) traffic and drop all traffic to 127/8 that doesn't use lo0 -A INPUT -i lo -j ACCEPT -A INPUT -i ! lo -d 127.0.0.0/8 -j REJECT # Accepts all established inbound connections -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT # Allows all outbound traffic # You can modify this to only allow certain traffic -A OUTPUT -j ACCEPT # Allows HTTP and HTTPS connections from anywhere (the normal ports for websites) -A INPUT -p tcp --dport 80 -j ACCEPT -A INPUT -p tcp --dport 443 -j ACCEPT # Allows SSH connections # # THE -dport NUMBER IS THE SAME ONE YOU SET UP IN THE SSHD_CONFIG FILE # -A INPUT -p tcp -m state --state NEW --dport 22 -j ACCEPT # Allow ping -A INPUT -p icmp -m icmp --icmp-type 8 -j ACCEPT # log iptables denied calls -A INPUT -m limit --limit 5/min -j LOG --log-prefix "iptables denied: " --log-level 7 # Reject all other inbound - default deny unless explicitly allowed policy -A INPUT -j REJECT -A FORWARD -j REJECT COMMIT
Only update specific packages
yum update packagename
exp:
yum update httpd
Configure SELinux to be permissive
To modify SELINUX we need to edit the file /etc/selinux/config, do not forget to become root before modifying the files.
nano /etc/selinux/config
Search for the line that reads :
SELINUX=enforcing
The following alternative options are available :
permissive and disabled
I prefer the service to function under “permissive”.
SELINUX=permissive
Now, reboot the system and the changes should take effect.