Useful Shell Commands
Manage Files and Folders
Copy all files in subfolders to the current folder. (Used when changed the filestorage rule in UCM)
find . -type f -exec mv -t . {} +
Find Size of subfolders
du -sh *
Find a String in all files
sed -i 's/\/u01\/Oracle\/Middleware\/user_projects\/domains/\/mnt/g' *.hda
Recursively
find . -name *.hda -exec sed -i 's/\/u01\/Oracle\/Middleware\/user_projects\/domains/\/mnt/g' {} +
Manage Partitions and Disk
List the available Disk
fdisk -l
List the mounted disk and space available
df -k
Mount disk
mount /dev/sdf /ebs
Format Disk
mkfs.ext3 /dev/sdf
Resize partition to the full available disk
resize2fs /dev/xvda1
Keep Mounts after restart
Edit /etc/fstab and add
/dev/xvdi /media/newdrive/ ext3 defaults,noatime 0 0
/dev/xvdj /u01 ext3 defaults,noatime 0 0
/dev/xvdj /u01 ext3 defaults,noatime 0 0
Firewall
Enable VNC connections (port 5901)
/etc/init.d/iptables -I INPUT 1 -p tcp --dport 5901 -j ACCEPT
/etc/init.d/iptables save
/etc/init.d/iptables save
Disable iptables
/etc/init.d/iptables save
/etc/init.d/iptables stop
chkconfig iptables off
/etc/init.d/iptables stop
chkconfig iptables off
For RHEL
service firewalld stop
systemctl disable firewalld
Swap Space
Check Swap Space
swapon -s
Add Swap Space
- Create a new swap file
dd if=/dev/zero of=/myswapfile1 bs=1M count=1024 - Change permission to only root
chmod 600 /myswapfile1 - setup file as swap
mkswap /myswapfile1 - Enable new swap space
swapon /myswapfile1 - to keep after reboot, add the following to /ect/fstap
/myswapfile1 swap swap defaults 0 0
Network
Check If IPv6 is loaded
lsmod | grep ipv6
Change Hostname
hostname newname.domain
Change Hostname after reboot:
Edit /etc/sysconfig/network and add the followin
HOSTNAME=newname.domain
Check If IPv6 is loaded
lsmod | grep ipv6
Disable IPv6
Edit/create the /etc/modprobe.d/modprobe.conf file and add the following:
options ipv6 disable=1
alias net-pf-10 off
alias ipv6 off
install ipv6 /bin/true- Edit /etc/sysconfig/network and add
NETWORKING_IPV6=no
IPV6INIT=no - Edit /etc/sysconfig/network-scripts/ifcfg-eth0 and add
IPV6INIT=no
IPV6_AUTOCONF=no
No comments:
Post a Comment