The Linux command line knows, simply by executing the following command:
biOos
Think before you type.
With great power comes great responsibility.
IF you don´t take control of your data, someone else Will.
The only Way to Stop a Hacker is to think like One
To gain knowledge there is no shortcut
Showing posts with label Linux. Show all posts
Showing posts with label Linux. Show all posts
05 May 2015
18 February 2013
How Do I check the root(/) partition with fsck at boot time?
sudo touch /forcefsck
Then reboot.
or
or
shutdown -rF now
From man:
The -F flag means 'force fsck'.
This only creates an advisory file /forcefsck which can be tested by the system when it comes up again. The boot rc file can test if this file is present, and decide to run fsck(1) with a special `force' flag so that even properly unmounted file systems get checked. After that, the boot process should remove /forcefsck.
biOos
29 December 2012
No grep itself Usage
I made a video for this example, see below:
The trick is to use grep [?]name of your process.
$ grep [n]gix || grep [a]apache
And so on...
[SRC]
biOos
18 November 2012
19 July 2012
VBoxManage showHDinfo TIP
- See nice informations about the use of disk
VBoxManage showhdinfo "path to the VMdisk.vdi"
Example of output:
With disk fixed
UUID: 81c1867e-ae5e-4d13-9111-4d37e951eff4
Accessible: yes
Logical size: 6144 MBytes
Current size on disk: 6144 MBytes
Type: normal (base)
Storage format: VDI
Format variant: fixed default
In use by VMs: pfSense 2.0.1 (UUID: a2f071b3)
Location: /guests/pfSense 2.0.1/pfSense2.0.1.vdi
With disk dynamic
UUID: 42aab591-9383-47a8-ad8f-599005c6c289
Accessible: yes
Logical size: 15360 MBytes
Current size on disk: 7035 MBytes
Type: normal (base)
Storage format: VDI
Format variant: dynamic default
In use by VMs: wServer2008 (UUID: 11e318a4-786a)
Location: /guests/wServer2008/wServer2008.vdi
biOos
VBoxManage showhdinfo "path to the VMdisk.vdi"
Example of output:
With disk fixed
UUID: 81c1867e-ae5e-4d13-9111-4d37e951eff4
Accessible: yes
Logical size: 6144 MBytes
Current size on disk: 6144 MBytes
Type: normal (base)
Storage format: VDI
Format variant: fixed default
In use by VMs: pfSense 2.0.1 (UUID: a2f071b3)
Location: /guests/pfSense 2.0.1/pfSense2.0.1.vdi
With disk dynamic
UUID: 42aab591-9383-47a8-ad8f-599005c6c289
Accessible: yes
Logical size: 15360 MBytes
Current size on disk: 7035 MBytes
Type: normal (base)
Storage format: VDI
Format variant: dynamic default
In use by VMs: wServer2008 (UUID: 11e318a4-786a)
Location: /guests/wServer2008/wServer2008.vdi
biOos
11 July 2012
Three Sysadmin Rules
While habits are good, sometimes rules might even be better, especially in the sysadmin world, when handling a production environment.
Rule #1: Backup Everything ( and validate the backup regularly )
Experienced sysadmin knows that production system will crash someday, no matter how proactive we are. The best way to be prepared for that situation is to have a valid backup.
If you don’t have a backup of your critical systems, you should start planning for it immediately. While planning for a backup, keep the following factors in your mind:
What software (or custom script?) you would use to take a backup? Do you have enough disk space to keep the backup? How often would you rotate the backups? Apart from full-backup, do you also need regular incremental-backup? How would you execute your backup? i.e Using crontab or some other schedulers?
If you don’t have a backup of your critical systems, stop reading this article and get back to work. Start planning for your backup immediately.
A while back in one of the research conducted by some group (don’t remember who did that), I remember they mentioned that only 70% of the production applications are getting backed-up. Out of those, 30% of the backups are invalid or corrupted.
Assume that Sam takes backup of the critical applications regularly, but doesn’t validate his backup. However, Jack doesn’t even bother to take any backup of his critical applications. It might sound like Sam who has a backup is in much better shape than Jack who doesn’t even have a backup. In my opinion, both Sam and Jack are in the same situation, as Sam never validated his backup to make sure it can be restored when there is a disater.
If you are a sysadmin and don’t want to follow this golden rule#1 (or like to break this rule), you should seriously consider quitting sysadmin job and become a developer. :-)
Rule #2: Master the Command Line ( and avoid the UI if possible )
There is not a single task on a Unix / Linux server, that you cannot perform from command line. While there are some user interface available to make some of the sysadmin task easy, you really don’t need them and should be using command line all the time.
So, if you are a Linux sysadmin, you should master the command line.
On any system, if you want to be very fluent and productive, you should master the command line. The main difference between a Windows sysadmin and Linux sysadmin is — GUI Vs Command line. Windows sysadmin are not very comfortable with command line. Linux sysadmin should be very comfortable with command line.
Even when you have a UI to do certain task, you should still prefer command line, as you would understand how a particular service works, if you do it from the command line. In lot of production server environment, sysadmin’s typically uninstall all GUI related services and tools.
If you are Unix / Linux sysadmin and don’t want to follow this rule, probably there is a deep desire inside you to become a Windows sysadmin. :-)
Rule #3: Automate Everything ( and become lazy )
Lazy sysadmin is the best sysadmin.
There is not even a single sysadmin that I know of, who likes to break this rule. That might have something to do with the lazy part.
Take few minutes to think and list out all the routine tasks that you might do daily, weekly or monthly. Once you have that list, figure out how you can automate those. The best sysadmin typically doesn’t like to be busy. He would rather be relaxed and let the system do the job for him.
[SRC]
cout << "bi0os" <<"\n";
03 July 2012
convert a man page into a web page (HTML)
Over the years, more ways of displaying and working with man pages have developed. For example, you can convert a man page into a web page (HTML) using the man2html command. For example:
$ whereis -m cat
cat: /usr/share/man/man1/cat.1.gz /usr/share/man/man1p/cat.1p.gz
$ cd /tmp ; cp /usr/share/man/man1/cat.1.gz .
$ gunzip cat.1.gz
$ man2html cat.1 > cat.1.html
$ links cat.1.html
The first command looks for the cat man page. The following commands copy that man page to the /tmp directory and unzip it. Next the man2html command converts the man page to HTML (cat.1.html file). The links command-line web browser then lets you view the webified man page from the shell. (You may need to install the elinks package to use the links or elinks text-based web browsers.)
See Also:
biOos
$ whereis -m cat
cat: /usr/share/man/man1/cat.1.gz /usr/share/man/man1p/cat.1p.gz
$ cd /tmp ; cp /usr/share/man/man1/cat.1.gz .
$ gunzip cat.1.gz
$ man2html cat.1 > cat.1.html
$ links cat.1.html
The first command looks for the cat man page. The following commands copy that man page to the /tmp directory and unzip it. Next the man2html command converts the man page to HTML (cat.1.html file). The links command-line web browser then lets you view the webified man page from the shell. (You may need to install the elinks package to use the links or elinks text-based web browsers.)
See Also:
biOos
31 May 2012
Find out the installation time of a Linux System ext3/ext4
tune2fs -l $(df -P / | awk 'NR==2 {print $1}') | sed -n 's/^.*created: *//p'
eg: Tue May 24 16:25:59 2011
SRC
biOos
27 May 2012
Useful commands - status
See loaded modules in apache
% httpd -M
Check which modules your PHP is using
% php -m
Know SELinux status
% sestatus -v
Mysql extended status
% mysqladmin -u root -p extended-status
biOos
14 May 2012
Download a list of Urls
cat urls.txt | wget -i- -T 10 -t 3 --waitretry 1
or
cat urls.txt | xargs -n1 curl -O --max-time 10 --retry 3
or even better:
Use wget's --input-file option directly:
wget -i urls.txt -T 10 -t 3 --waitretry 1
wget -i urls.txt -T 10 -t 3 --waitretry 1
biOos
06 April 2012
How to clear/reset DNS cache on Windows XP / Linux
Windows XP remembers failed ("Unable to resolve" - DNS requests) entries for a few minutes. This can be very unpleasant when moving and debugging/developing web-sites. As long as that failed entry sits in your DNS cache, your box will continue to give you a "Unable to resolve" error. By cleaning out your DNS cache, you can fix this problem.
Clear DNS cache on Windows XP
Start -> Run -> cmd [ENTER]
C:WINDOWS> ipconfig /flushdns
Windows IP Configuration
Successfully flushed the DNS Resolver Cache.
Clear DNS cache on Linux (Red Hat / Suse)
# service nscd restart
Shutting down Name Service Cache Daemon done
Starting Name Service Cache Daemon done
For both situations you need to be root/Administrator.
On FreeBSD, applications clients query the DNS server every time they need a DNS record.
[SRC]
biOos
Clear DNS cache on Windows XP
Start -> Run -> cmd [ENTER]
C:WINDOWS> ipconfig /flushdns
Windows IP Configuration
Successfully flushed the DNS Resolver Cache.
Clear DNS cache on Linux (Red Hat / Suse)
# service nscd restart
Shutting down Name Service Cache Daemon done
Starting Name Service Cache Daemon done
For both situations you need to be root/Administrator.
On FreeBSD, applications clients query the DNS server every time they need a DNS record.
[SRC]
biOos
26 January 2012
Arithmetic Expansion
The shell allows arithmetic to be performed by expansion. This allows us to use the shell prompt as a calculator:
[me@linuxbox ~]$ echo $((2 + 2))
4
Arithmetic expansion uses the following form:
$((expression))
where expression is an arithmetic expression consisting of values and arithmetic operators.
Arithmetic expansion supports only integers (whole numbers, no decimals) but can perform quite a number of different operations.
Table lists a few of the supported operators.
Spaces are not significant in arithmetic expressions, and expressions may be nested. For example, multiply 5² by 3:
[me@linuxbox ~]$ echo $(($((5**2)) * 3))
75
Single parentheses may be used to group multiple subexpressions. With this technique, we can rewrite the example above and get the same result using a single expansion instead of two:
[me@linuxbox ~]$ echo $(((5**2) * 3))
75
Here is an example using the division and remainder operators. Notice the effect of integer division:
[me@linuxbox ~]$ echo Five divided by two equals $((5/2))
Five divided by two equals 2
[me@linuxbox ~]$ echo with $((5%2)) left over.
with 1 left over.
See Also:

biOos
[me@linuxbox ~]$ echo $((2 + 2))
4
Arithmetic expansion uses the following form:
$((expression))
where expression is an arithmetic expression consisting of values and arithmetic operators.
Arithmetic expansion supports only integers (whole numbers, no decimals) but can perform quite a number of different operations.
Table lists a few of the supported operators.
Spaces are not significant in arithmetic expressions, and expressions may be nested. For example, multiply 5² by 3:
[me@linuxbox ~]$ echo $(($((5**2)) * 3))
75
Single parentheses may be used to group multiple subexpressions. With this technique, we can rewrite the example above and get the same result using a single expansion instead of two:
[me@linuxbox ~]$ echo $(((5**2) * 3))
75
Here is an example using the division and remainder operators. Notice the effect of integer division:
[me@linuxbox ~]$ echo Five divided by two equals $((5/2))
Five divided by two equals 2
[me@linuxbox ~]$ echo with $((5%2)) left over.
with 1 left over.
See Also:
biOos
06 December 2011
HowTo determine What version of NFS is Running?
Very simple answer:
~# nfsstat -m
; )
biOos
~# nfsstat -m
/opt/shared from 10.10.10.10:/u01/shared
Flags: rw,vers=3,rsize=32768,wsize=32768,soft,intr,proto=tcp,timeo=600
; )
biOos
24 September 2011
Wget TIPz & Trickz
~/.wgetrc and /etc/wgetrc
If you need to go via a proxy server, the ~/.wgetrc file can be used
to set proxy settings for the wget tool.
For example:
http_proxy = http://proxyserver.intranet.example.com:8080/
https_proxy = http://proxyserver.intranet.example.com:8080/
proxy_user = steve
proxy_password = letmein
You can also set equivalent variables in the shell.
The /etc/wgetrc file will be processed first, but is overruled by
the user’s ~/.wgetrc (if it exists). You must use chmod 0600 ~/.wgetrc
for ~/.wgetrc to be processed — this is for your own protection; valid passwords should not be visible by anyone but yourself! If the permissions are any more open than 0600, wget will ignore the file.
biOos
If you need to go via a proxy server, the ~/.wgetrc file can be used
to set proxy settings for the wget tool.
For example:
http_proxy = http://proxyserver.intranet.example.com:8080/
https_proxy = http://proxyserver.intranet.example.com:8080/
proxy_user = steve
proxy_password = letmein
You can also set equivalent variables in the shell.
The /etc/wgetrc file will be processed first, but is overruled by
the user’s ~/.wgetrc (if it exists). You must use chmod 0600 ~/.wgetrc
for ~/.wgetrc to be processed — this is for your own protection; valid passwords should not be visible by anyone but yourself! If the permissions are any more open than 0600, wget will ignore the file.
biOos
16 June 2011
For To be a LPIC-3 Core or Specialty
Requirements: Core - passing the 301 exam. Specialty - passing the 301 exam and any one of the LPI 302 - 306 exams to receive the respective specialty certification.
Overview of Tasks: to pass LPI-303 (Security) Specialty someone should:
Have necessary skills and experience as outlined in LPIC-3 "Core" exam Design and implement customized solutions to complex automation problems such as multi-site enterprises and heavy-duty Internet sites Initiate projects and work against a budget. Supervise assistants and help troubleshoot problems. Serve as a consultant to higher management.
Help for Study:



[*] http://blog.ooz.ie/search/label/LPIC
[*] http://www.rootkit.nl/files/book_lpic-3_301.html
[*] http://en.wikibooks.org/wiki/LPI_Linux_Certification
[*] http://www.ibm.com/developerworks/linux/lpi/301.html
[*] http://lpi.universe-network.net/doku.php?id=wiki:certification:lpic301
biOos
Overview of Tasks: to pass LPI-303 (Security) Specialty someone should:
Have necessary skills and experience as outlined in LPIC-3 "Core" exam Design and implement customized solutions to complex automation problems such as multi-site enterprises and heavy-duty Internet sites Initiate projects and work against a budget. Supervise assistants and help troubleshoot problems. Serve as a consultant to higher management.
Help for Study:
[*] http://blog.ooz.ie/search/label/LPIC
[*] http://www.rootkit.nl/files/book_lpic-3_301.html
[*] http://en.wikibooks.org/wiki/LPI_Linux_Certification
[*] http://www.ibm.com/developerworks/linux/lpi/301.html
[*] http://lpi.universe-network.net/doku.php?id=wiki:certification:lpic301
biOos
27 May 2011
Locating the Address from the DHCP Server
No matter what OS the client uses, you can locate the MAC address from the DHCP server in several ways. One method is to configure the DHCP client to use DHCP and then activate its network interface. The DHCP client should pick up an address. You can then examine the DHCP server’s logs for evidence of a lease granted for that address. The DHCP leases file typically (/var/lib/dhcp/dhcpd.leases) should include a multiline entry identifying the IP address and MAC address.
Typing grep dhcpd /var/log/messages | tail -n 1 or grep dhcpd /var/log/daemon.log | tail -n 1 as root should also reveal an entry with the IP address and MAC address in question. (If some other DHCP activity occurs between the target system’s lease being granted and you typing this command, though, that activity will show up instead.
Increase the number from 1 to 2 or higher to reveal earlier entries.) Finally, you can type ping -c 1 ip.addr; /sbin/arp ip.addr, where ip.addr is the IP address, to learn the MAC address of the computer. This last approach will also work if you temporarily configure the future DHCP client with a static IP address.
biOos
Typing grep dhcpd /var/log/messages | tail -n 1 or grep dhcpd /var/log/daemon.log | tail -n 1 as root should also reveal an entry with the IP address and MAC address in question. (If some other DHCP activity occurs between the target system’s lease being granted and you typing this command, though, that activity will show up instead.
Increase the number from 1 to 2 or higher to reveal earlier entries.) Finally, you can type ping -c 1 ip.addr; /sbin/arp ip.addr, where ip.addr is the IP address, to learn the MAC address of the computer. This last approach will also work if you temporarily configure the future DHCP client with a static IP address.
biOos
21 May 2011
VSftpd with virtual users and working!
[1]
put the below on the file /etc/vsftpd.conf
listen=YES
anonymous_enable=NO
local_enable=YES
virtual_use_local_privs=YES
write_enable=YES
pam_service_name=vsftpd.virtual
guest_enable=YES
user_sub_token=$USER
local_root=/var/www/sites/$USER
chroot_local_user=YES
##chown_uploads=YES
##chown_username=ftp
hide_ids=YES
[2]
put the below on the file /etc/pam.d/vsftpd.virtual
#%PAM-1.0
auth required pam_userdb.so db=/etc/vsftpd/v-users crypt=hash
account required pam_userdb.so db=/etc/vsftpd/v-users crypt=hash
session required pam_loginuid.so
[3]
install these packages:
[4]
last steps:
[a] db_load -T -t hash -f passwd.txt v-users.db
[b] chmod 600 v-users.db
[c] rm -f passwd.txt
to add additional users, repeat steps a-b-c
[5]
creating the directory where the files will be:
put the files in the folder to download User:
eg: cp /etc/motd /var/www/sites/user1
ftp ftp-ip-server
user: user1
pass: user1pass
[6]
Troubleshooting:
[7]
put in the ftpd daemon startup:
biOos
put the below on the file /etc/vsftpd.conf
listen=YES
anonymous_enable=NO
local_enable=YES
virtual_use_local_privs=YES
write_enable=YES
pam_service_name=vsftpd.virtual
guest_enable=YES
user_sub_token=$USER
local_root=/var/www/sites/$USER
chroot_local_user=YES
##chown_uploads=YES
##chown_username=ftp
hide_ids=YES
[2]
put the below on the file /etc/pam.d/vsftpd.virtual
#%PAM-1.0
auth required pam_userdb.so db=/etc/vsftpd/v-users crypt=hash
account required pam_userdb.so db=/etc/vsftpd/v-users crypt=hash
session required pam_loginuid.so
[3]
install these packages:
yum install db4-utils db4
[4]
last steps:
cd /etc/vsftpd
echo user1 > passwd.txt
echo user1passs >> passwd.txt
[a] db_load -T -t hash -f passwd.txt v-users.db
[b] chmod 600 v-users.db
[c] rm -f passwd.txt
to add additional users, repeat steps a-b-c
[5]
creating the directory where the files will be:
mkdir /var/www/sites
mkdir -p /var/www/sites/{user1,user2}
chown -R ftp:ftp /var/www/sites
put the files in the folder to download User:
eg: cp /etc/motd /var/www/sites/user1
service vsftpd restart
ftp ftp-ip-server
user: user1
pass: user1pass
[6]
Troubleshooting:
tail -30 /var/log/secure
tail -30 /var/log/messages
[7]
put in the ftpd daemon startup:
chkconfig vsftpd on
biOos
10 May 2011
Building The Kernel Binary
Setting up an appropriate .config file is the most important part of the Linux kernel configuration process, but you must jump through several more hoops to turn that file into a finished kernel.
Here’s an outline of the entire process:
• cd to the top level of the kernel source directory.
• Run make xconfig,make gconfig, or make menuconfig.
• Run make dep (not required for kernels 2.6.x and later).
• Run make clean.
• Run make.
• Run make modules_install.
• Copy arch/i386/boot/bzImage to /boot/vmlinuz.
• Copy arch/i386/boot/System.map to /boot/System.map.
• Edit /etc/lilo.conf (LILO) or /boot/grub/grub.conf (GRUB) to add a configuration line for the new kernel.
• If you’re using LILO, run /sbin/lilo to install the reconfigured boot loader.
The make clean step is not always strictly necessary, but it is generally a good idea to start with a clean build environment. In practice, many problems can be traced back to this step having been skipped.
See Also:


biOos
Here’s an outline of the entire process:
• cd to the top level of the kernel source directory.
• Run make xconfig,make gconfig, or make menuconfig.
• Run make dep (not required for kernels 2.6.x and later).
• Run make clean.
• Run make.
• Run make modules_install.
• Copy arch/i386/boot/bzImage to /boot/vmlinuz.
• Copy arch/i386/boot/System.map to /boot/System.map.
• Edit /etc/lilo.conf (LILO) or /boot/grub/grub.conf (GRUB) to add a configuration line for the new kernel.
• If you’re using LILO, run /sbin/lilo to install the reconfigured boot loader.
The make clean step is not always strictly necessary, but it is generally a good idea to start with a clean build environment. In practice, many problems can be traced back to this step having been skipped.
See Also:
biOos
24 March 2011
20 March 2011
Create and Delete a PostgreSQL Database from PSQL CLI
Easily create or drop a database via the psql CLI using the below syntax.
Create a PostgreSQL Database: Just modify the database_name to the name you prefer for your new database.
Delete a PostgreSQL Database: Again just modify the database_name to the name of the database you would like to remove from Postgres.
Create a PostgreSQL Database: Just modify the database_name to the name you prefer for your new database.
create database database_name
Delete a PostgreSQL Database: Again just modify the database_name to the name of the database you would like to remove from Postgres.
drop database database_nameBelow is output from a shell where a connection is made to Postgres with psql, a database is added, and then the same database is deleted. In the example below the database that is added and removed is called “newdb”.
[root@server ~]# psql -U postgres Welcome to psql 8.3.5, the PostgreSQL int terminal. Type: copyright for distribution terms h for help with SQL commands ? for help with psql commands g or terminate with semicolon to execute query q to quit postgres=# create database newdb; CREATE DATABASE postgres=# drop database newdb; DROP DATABASE postgres=# q [root@server ~]#
biOos
Subscribe to:
Posts (Atom)
