Edit the file /etc/sysconfig/network-scripts/ifcfg-eth0 and Change the ONBOOT line’s value to ‘yes’
Tag Archives: Linux
Linux Rename Username CentOS
You can change / rename the username using the below command.
usermod -l login-name old-name
The name of the user will be changed from old-name to login_name. Nothing else is changed. In particular, the user’s home directory name should probably be changed to reflect the new login name.
Install Composer Linux CentOS
Make sure system is uptodate.
yum -y update
Chnage the directory to tmp and run the follwing commands.
cd /tmp/ curl -sS https://getcomposer.org/installer | php mv composer.phar /usr/local/bin/composer chmod +x /usr/local/bin/composer
Now you can check the composer version as follows
[root@localhost bin]# composer -V Composer version 1.6.5 2018-05-04 11:44:59
SFTP User Creation CentOs
Step 1. Crate Group
groupadd sftponly
Step 2. Create user account
useradd -d /home/sftp/MYUSER -s /bin/false -G sftponly MYUSER
Step 3. Create a password for your username.
passwd MYUSER
Step 4. Ensure the following line is commented out in your sshd configuration file ( File Location: /etc/ssh/sshd_config )
# Edit the sshd_config file which holds the SSH/SFTP configuration
vi /etc/ssh/sshd_config
# Ensure this below Line has a hash symbol, # in front of it
#Subsystem sftp /usr/lib/openssh/sftp-server
# Ensure that this below line is added directly below the line you just commented out with a hash symbol #
Subsystem sftp internal-sftp
Step 5. Add the following to the bottom of the same file (it must be at the very bottom)
Match Group sftponly
ChrootDirectory %h
X11Forwarding no
AllowTCPForwarding no
ForceCommand internal-sftp
Step 6. Test the changes with sshd before restarting the service, please note it’s important you do this correctly, or may break your sshd configuration
sshd -t
service sshd restart
Step 7. Give proper ownership to the newly created folder
chown root:root /home/sftp/MYUSER
Step 8. Test SFTP credential is working:
# Connect to SFTP using the myuser, replace myuser with the user you’ve chosen
sftp myuser@localhost
myuser@localhost’s password:
Extract Unique IP Addresses From Apache Log Linux CentOs
Log in to your account using SSH and change to the directory where the apache logs available.
Then issue the command given below.
awk ‘{print $1}’ access.log | sort | uniq -c | sort -n | tail -n 10
Disk Space Usage CentOs Linux
Check File System Disk Space Usage : df
Display Information of all File System Disk Space Usage : df -a
Show Disk Space Usage in Human Readable Format : df -h
Display Information of /home File System : df -hT /home
Display Information of File System in Bytes : df -k
Display Information of File System in MB : df -m
Display Information of File System in GB : df -h
Display File System Inodes : df -i
Display File System : df -T
Include Certain File System : df -t ext
Exclude Certain File System : df -x ext
Display Information of df Command: df --help
Apache Directives
Apache directives are a set of rules which define how your server should run, number of clients that can access your server, etc. you can change them by editing the httpd.conf and related files to meet your requirements
Below given are the some of the important directives
- Alias
- AliasMatch
- CheckSpelling
- DocumentRoot
- ErrorDocument
- Options
- ProxyPass
- ProxyPassReverse
- ProxyPassReverseCookieDomain
- ProxyPassReverseCookiePath
- Redirect
- RedirectMatch
- RewriteCond
- RewriteRule
- ScriptAlias
- ScriptAliasMatch
- UserDir
Apache mod_rewrite
This module uses a rule-based rewriting engine (based on a regular-expression parser) to rewrite requested URLs on the fly. It supports an unlimited number of rules and an unlimited number of attached rule conditions for each rule, to provide a really flexible and powerful URL manipulation mechanism. The URL manipulations can depend on various tests, of server variables, environment variables, HTTP headers, or time stamps. Even external database lookups in various formats can be used to achieve highly granular URL matching.
This module operates on the full URLs (including the path-info part) both in per-server context (httpd.conf) and per-directory context (.htaccess) and can generate query-string parts on result. The rewritten result can lead to internal sub-processing, external request redirection or even to an internal proxy throughput.
Apache Modules
Below given are the some of the important Apache modules
- mod_alias
- mod_proxy
- mod_rewrite
- mod_userdir
- mod_speling
- mod_vhost_alias
Apache mod_userdir
This module allows user-specific directories to be accessed using the http://example.com/~user/ syntax.
The UserDir directive sets the real directory in a user’s home directory to use when a request for a document for a user is received.