Showing posts with label Linux Shell Commands. Show all posts
How To Setup Default umask Under Linux?
Umask is the number subtracted from the standard permissions when creating a file. Example: each new folder is by default created with 777, so when umask is set to 022, the result is that the permissions will be 777 – 022 = 755.
Most of the time umask will already be set by your distro to 022 but you can change it if you like. You can see what umask value is set with:
If you want to change umask for temporally,
Note: These value will stay until you log out and then return to its default value.
To make it permanent, edit /etc/bashrc or to your ~/.bash_profile.
Most of the time umask will already be set by your distro to 022 but you can change it if you like. You can see what umask value is set with:
# umask
0022If you want to change umask for temporally,
# umask 0044
Note: These value will stay until you log out and then return to its default value.
To make it permanent, edit /etc/bashrc or to your ~/.bash_profile.
route add in Linux
| Route manipulates the kernel’s IP routing tables. Its primary use is to set up static routes to specific hosts or networks via an interface after it has been configured with the ifconfig program. |
| When the add or del options are used, route modifies the routing tables. Without these options, route displays the current contents of the routing tables. |
Add static route using “route add”: |
# route add -net 192.168.100.0 netmask 255.255.255.0 gw 192.168.1.1 dev eth0 |
| If you want persistent static route, you need to edit /etc/sysconfig/network-scripts/route-eth0 file to define static routes for eth0 interface. |
| # vim /etc/sysconfig/network-scripts/route-eth0 |
GATEWAY0=192.168.1.1 |
NETMASK0=255.255.255.0 |
ADDRESS0=192.168.100.0 |
| Save and close the file. Restart networking: |
# service network restart |
Verify new routing table by, |
| # route –n or # netstat –nr |
Change Default User Home Directory While Adding A New User
By default, when we create or add users to Linux System, user’s default home directory is created to /home. To change default directory to /opt/, we need to change few settings as mentioned below: | |||||||||
| | |||||||||
| STEP 1: Open /etc/default/useradd | |||||||||
| | |||||||||
| # nano /etc/default/useradd | |||||||||
| The default home directory defined by HOME variable, find line that read as follows: | |||||||||
| | |||||||||
| HOME=/home replace to HOME=/opt/ | |||||||||
| | |||||||||
| Save and close the file. Now you can add user using regular useradd command: | |||||||||
| | |||||||||
| # useradd uddika | |||||||||
| # passwd -d uddika | |||||||||
| | |||||||||
| Verify user information: | |||||||||
| | |||||||||
| # finger uddika | |||||||||
| Output: | |||||||||
|
Range of IPS on single Ethernet
How to create a range of ip addresses on ethx. Create a range file in /etc/sysconfig/network-scripts
[root@daddylinux~]# cd /etc/sysconfig/network-scripts
[root@daddylinux~]# nano ifcfg-eth0-range1 Enter this Parameters
DEVICE=eth0 BOOTPROTO=static HWADDR=00:04:75:D4:C8:F9 IPADDR_START=192.168.0.6 IPADDR_END=192.168.0.10 CLONENUM_START=1 NETMASK=255.255.255.0 ONBOOT=yes TYPE=Ethernet
CLONENUM_START -- interface clone number to start using for this range. # eg "1"
Which would start at eth0:1