1) To start the GUI interface in linux
startx &
2) To install unrar(extract .rar package) in a fedora desktop, do the following
su -c "rpm -Uvh http://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-stable.noarch.rpm"su -c "rpm -Uvh http://download1.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-stable.noarch.rpm"su -c "yum install unrar" 3) How to Restart the Apache Server? /etc/init.d/httpd restart4) How to mount iso image on linux?
# su - # mkdir /mnt/test # mount file.iso -o loop -t iso9660 /mnt/test
5) How to Re-Mount /etc/fstab without Restarting?
You have added new entry in your /etc/fstab file to mount a drive or partition. To mount those new partitions you would normally reboot your PC. There is a simple way which will Re-Mount the drives in your /etc/fstab file. Run as root.
mount -a
6) To set environmental variables for vi Editor
i) cd
ii) vi .exrc
set ic #(to ignore case while searching the vi editor)
set paste #(to avoid intending and commenting while copy pasting from web)
b) To delete particular lines based on search criteria in an vi editor
Using vi global commands
Using vi, you can issue global commands from command mode. If you are not sure of the case used, you can issue this command from vi command mode before you make the global change:
:set ic
(set ignorecase)
- :g/outdated/d
- This command tells vi to do a global search for "outdated" and to delete any line containing that text.
- :g/out dated/d
- This command tells vi to do a global search for "out dated" and to delete any line containing that text--including the space.
7) General
1) For clearing java cache.
rm -fr ~/.java
-----------------------------------
3) Replace the bracket contents in shell
:%s/step:\([^ ]\)/step: \1/cg
-----------------------------------
4) Commands
which syslog-ng
yum search syslog-ng
yum install syslog-ng.i386
pkill syslog-ng
------------------------------------
7) To restore last known good configuration in windows xp
i) Press F8
-----------------------------------
8) Replace a text with enter character
%s /></> </cg
press Ctrl+V and Ctrl+M
-------------------------------------10) lineBreaker command
grep "admin" -ir * | lineBreaker
will display the lines with linebreak.
------------------------------------
12) To generate CA Certificate using GUI
tinyca2
--------------------------------
13) To trace a process using pid, use the following
strace -p 13890
-------------------------------
14) Command to increase date by 3 days
date --set='+8 days'
--------------------------------
16) To insert space before a paragraph
- Cntrl+V select the space
- Shift+Delete
- u - Undo
- Shift+P for pasting
-----------------------------------
19) To capture tcpdump
tcpdump -i eth0 -w linux.cap
----------------------------------
20) To view the files in apache,
check the logs in
/etc/httpd/logs/error_log
/etc/httpd/modsecurity.d/modsecurity_crs_50_outbound.conf
/etc/init.d/httpd restart
/etc/httpd/modsecurity.d/modsecurity_crs_50_outbound.conf
/etc/init.d/httpd restart
--------------------------------
-------------------------------22)
To set ignore case in vi automatically
vi ~/.exrc
:set ic
--------------------------------
1) To view APACHE Error Logs:
su -
tail -f /var/log/httpd/error_log
2) Linux: How to send email in command line?
cat ~/license.dat | mutt -s "license 10.32.2.56" arul@infoblox.com
3) How do you check whether a port currently being used?
i) netstat -a | grep http
or
ii) lspf -i: 80
(list open files)
4) Command to exit from login prompt in telnet:
Cntrl + ]
dmseg
(print or control the kernel ring buffer)
6) Make an ISO Image on Linux
To make an ISO from your CD/DVD, place the media in your drive but do not mount it. If it automounts, unmount it.
dd if=/dev/dvd of=dvd.iso # for dvd
dd if=/dev/cdrom of=cd.iso # for cdrom
dd if=/dev/scd0 of=cd.iso # if cdrom is scsi
To make an ISO from files on your hard drive, create a directory which holds the files you want. Then use the mkisofs command.
mkisofs -o /tmp/cd.iso /tmp/directory/
This results in a file called cd.iso in folder /tmp which contains all the files and directories in /tmp/directory/.
7) Vncviewer display problems
When you connect to Centos linux using vncviewer and you see grey screen
with three options, you need to do the below
vi ./.vnc/xstartup
Uncomment the below lines
unset SESSION_MANAGER
exec /etc/X11/xinit/xinitrc
Add the following at the end of the file
startkde &
8) Error SIOCADDRT: No such process
Solution: Most probably, the gateway is wrong, set it correctly and the error
message will go away.
-------------------------------------------------------------
9) IPv6
a) Re-booting removes IPv6 address solution:
IPv6 Configuration in linux from command line:
# vi /etc/sysconfig/networkNETWORKING_IPV6=yes
# vi /etc/sysconfig/network-scripts/ifcfg-eth0
IPV6INIT=yes IPV6ADDR=2607:f0d0:1002:0011:0000:0000:0000:0002 IPV6_DEFAULTGW=2607:f0d0:1002:0011:0000:0000:0000:0001
#route -n -A inet6
b) Add IPv6 address
#sudo ifconfig eth0 inet6 add
2001:db8:a20::6666/64
or
#ip addr add 2001:db8::1/64 dev eth0
or
#ip addr add 2001:db8::1/64 dev eth0
c) Add IPv6 Default route
#ip -6 route add default via
2001:db8:a20::1 dev eth0
d) To see the IPv6 route
#/sbin/ip -6 route show dev eth0
or
#/sbin/route -A inet6
or
#
or
#
route -n -A inet6
e) To delete IPv6 Default route
# ip -6 route del default via fe80::4255:39ff:fee6:ba3f dev eth0
f) Add IPv6 route
#/sbin/route -A inet6 add 2000::/3 dev eth0
or
# /sbin/ip -6 route add 2000::/3 dev eth0 metric 1
g) IPv6 tools
# ping6
# traceroute6
# tracepath6
# ip -6
# tcpdum ip6
# ip -6 route del default via fe80::4255:39ff:fee6:ba3f dev eth0
f) Add IPv6 route
#/sbin/route -A inet6 add 2000::/3 dev eth0
or
# /sbin/ip -6 route add 2000::/3 dev eth0 metric 1
g) IPv6 tools
# ping6
# traceroute6
# tracepath6
# ip -6
# tcpdum ip6
======================================================================== 10) Command to set/see what services will start during boot
su -
ntsysv
=====================================
11) How to burn ISO image to a bootable DVD/CD in Fedora 14+
You can use GnomeBaker to do it.
Go to Tools->Burn DVD/CD image-> Select ISO image->click ok->click Start
=====================================
12) To view the total diskspace in Linux,
Execute the following command
a) To view in GUI
palimpsest &
or
b) Command line view
df -h
or
c) Command line view
fdisk -l | grep Disk=======================================
13) To list the rpm installed in your linux
rpm -qa
To grep for particular installed package (qa = query all)
# rpm -qa|grep -i "ldap"
To list where it is installed
(ql = query list)
# rpm -ql openldap-clients
==========================================
14) To check the linux version in command line
# cat /etc/issue
==========================================
15) Linux command to convert video .mov files to .avi files
#yum install ffmpeg
#ffmpeg -i path/video1.mov path/movie2.avi
===========================================
16) To query MX/SRV records using nslookup command in Windows
C:\Users\arul>nslookup
> server 10.34.8.70
Default Server: [10.34.8.70]
Address: 10.34.8.70
> set q=srv
> srv2.http.del.infoblox.com
Server: [10.34.8.70]
Address: 10.34.8.70
Non-authoritative answer:
srv2.http.del.infoblox.com SRV service location:
priority = 0
weight = 0
port = 0
svr hostname = 7.7.7.7
>
> set q=a
> c2.infoblox.com
Server: [10.34.8.70]
Address: 10.34.8.70
Name: a1.del.infoblox.com
Address: 1.1.1.1
Aliases: c2.infoblox.com
===================================================
17) Perl Getopt and Getopts summary:
use Getopt::Std;
getopt('oDI'); # -o, -D & -I take arg. Sets $opt_* as a side effect.
getopt('oDI', \%opts); # -o, -D & -I take arg. Values in %opts
getopts('oif:'); # -o & -i are boolean flags, -f takes an argument
# Sets $opt_* as a side effect.
getopts('oif:', \%opts); # options as above. Values in %opts
==================================================
18) How to enable ssh in latest Fedora 17, Fedora 18 and above
i) ]#service sshd start
Note: Forwarding request to 'systemctl enable sshd.service'.
To start sshd service upon boot, you can use this command
chkconfig sshd on
iii) When you reboot your Fedora, sshd service will be loaded automatically.
You can check if sshd running using this command
]#service sshd status
==================================================
19) Basic Awk scripts
a) awk 'pattern {action}' input-file > output-file
b) awk '{ print $5 }' table1.txt > output1.txt
If the column separator is something other than spaces or tabs, such as a
comma, you can specify that in the awk statement as follows:
c) awk -F, '{ print $3 }' table1.txt > output1.txt
The list of statements inside the curly brackets ('{','}') is called a
block. If you put a conditional expression in front of a block, the
statement inside the block will be executed only if the condition is
true.
d) awk '$7=="\$7.30" { print $3 }' table1.txt
You can also use regex as condition. For example:
e)awk '/30/ { print $3 }' table1.txt
Ex:
/sbin/ifconfig p34p1 | awk '/inet/ { print $2 } '
f) awk '{ print ($2 * $3) + $7 }'
==================================================20) Basic Sed scripts
i) a)
sed 's/6.30/7.30/' songs.txt > songs2.txt
To find and replace within the same file
b)
sed 's/6.30/7.30/' -i /tmp/songs.txt
ii) date | sed 's/20/30/'
Thu Mar 14 15:10:11 PDT 3013
iii) To filter lines in a file or stream. For example if you only want see the lines
containing "day" you could use:
sed -n '/day/p' week.txt > days.txt
==================================================
21) To skip searching particular directories in find command
If you want to search for file name 'meminfo' recursively in the current directory but want to skip the directorys "./import" and './mnt', use the following command
find . -path ./import -prune -o -path ./mnt -prune -o -name "meminfo"
find [source dir] -path [source dir]/[sub dir 1] -prune -o -path [source dir]/[sub dir 2] -prune -o -name [filename]
22)
To avoid the below warning when using LWP:Useragent against a HTTPS site:
*******************************************************************
Using the default of SSL_verify_mode of SSL_VERIFY_NONE for client
is depreciated! Please set SSL_verify_mode to SSL_VERIFY_PEER
together with SSL_ca_file|SSL_ca_path for verification.
If you really don't want to verify the certificate and keep the
connection open to Man-In-The-Middle attacks please set
SSL_verify_mode explicitly to SSL_VERIFY_NONE in your application.
*******************************************************************
If you are worried about mitm attack, Use the following in LWP::UserAgent construction:my $ua = LWP::UserAgent->new(
ssl_opts => {
verify_hostname => 0,
SSL_verify_mode => 0x00
});
==============================================================================================
23) To view the output as well as capture it, use tee command
tcpdump -i p34p1 | tee dat
==============================================================================================
24) To disable selinux on Fedora
vi /etc/selinux/config
SELINUX=disabled
To check status
/usr/sbin/getenforce
#setenforce 0
Use Enforcing or 1 to put SELinux in enforcing mode.
Use Permissive or 0 to put SELinux in permissive mode.
==============================================================================================
25) In Fedora, if gnome has crashed and you want to login to command prompt, press
Cntrl + Alt + F6
===============================================================================================
26) Find a certain word from all of the directories in current path recursively
find . -name "$1" | xargs grep -is "$file"
===============================================================================================
26) To get the snmp trapssnmptrapd -m SMI-MIB.txt:TRAP-MIB.txt -d -Lf ./snmp.log -F "%v %w %W"
27) To install Fedora from usb drive on linux os===============================================================================================
a) Download fedora to the local drive on linux
b) su -c 'yum install liveusb-creator'
c) Open liveusb-creator GUI
d) Select iso from hard disk
e) On the target, select usb stick and click create live usb
f) Once it is done 100%, reboot the linux os and select the
option to install from usb stick
g) Continue to install new fedora os from usb
==================================================
28) Windows:
Copy Files recursively from inside directory to outside using batch file
Execute the following command from your folder:
for /r /d %F in (*) do @copy /y "%F\*"
============================================================================================
29) Wget command to download songs
wget -r -l1 -H -t1 -nd -N -np -A.mp3 -erobots=off -i ~/mp3blogs.txt
wget -r -l1 -H -t1 -nd -N -np -A.mp3 -erobots=off "http://songsdownload.com"
====================================================================================
30) tee command
The following command (with the help of tee command) writes the output both to the screen (stdout) and to the file.
# ls | tee file
By default tee command overwrites the file. You can instruct tee command to append to the file using the option –a as shown below.
# ls | tee -a file
You can also write the output to multiple files as shown below.
$ ls | tee file1 file2 file3
==========================================================================
31)
Many times you must have observed that clipboard operations like copy/cut and paste suddenly stops workings with the vncviewer. The main reason for this there is a program called as vncconfig responsible for these clipboard transfers. Some times the program may get closed because of some bug in vnc or some other reasons like you closed that window.
To get those clipboard operations back you need to run the program "vncconfig &".
After this your clipboard actions should work fine with out any problems.
============================================================
32) ifconfig deprecated. ip command line examples
1. How to Assign a IP Address to Specific Interface
# ip addr add 192.168.50.5 dev eth1
2. How to Check an IP Address
# ip addr show
3. How to Remove an IP Address
# ip addr del 192.168.50.5/24 dev eth1
4. How to Enable Network Interface
# ip link set eth1 up
5. How to Disable Network Interface
# ip link set eth1 down
6. How do I Check Route Table?
# ip route show
7. How do I Add Static Route
# ip route add 10.10.20.0/24 via 192.168.50.100 dev eth0
8. How to Remove Static Route
# ip route del 10.10.20.0/24
9. How do I Add Persistence Static Routes
# vi /etc/sysconfig/network-scripts/route-eth0
10.10.20.0/24 via 192.168.50.100 dev eth0
# /etc/init.d/network restart
10. How do I Add Default Gateway
# ip route add default via 192.168.50.100
11. How do I delete Default Gateway
# ip route del default gw 192.168.50.100
# ip route del default gw 192.168.50.100
==============================================
33) To set indentation to 4 spaces for each tab
vi ~/.vimrc
set tabstop=8 softtabstop=0 expandtab shiftwidth=4 smarttab
===========================34) To find your public ip using curl
curl ifconfig.me
78.22.13.44
==========================
35) To get the laptop model information
sudo dmidecode | grep -A 9 "System Information"
'-A 9' option is to get 9 lines after "System Information"
'-B 9' option is to get 9 lines before "System Information"
36) How to Setup Ubuntu vncserver for remote viewing and avoid grey screen
https://poweruphosting.com/blog/setup-vnc-server-on-ubuntu/
i) sudo apt install xfce4 xfce4-goodies tightvncserver
ii) vncserver
iii) vncserver -kill :1
iv) mv ~/.vnc/xstartup ~/.vnc/xstartup.bak
v) vi ~/.vnc/xstartup
#!/bin/bash
xrdb $HOME/.Xresources
startxfce4 &
vi) sudo chmod +x ~/.vnc/xstartup
7) If you see grey screen, add the following
#!/bin/sh
def
export XKL_XMODMAP_DISABLE=1
unset SESSION_MANAGER
unset DBUS_SESSION_BUS_ADDRESS
gnome-panel &
gnome-settings-daemon &
metacity &
nautilus &
gnome-terminal &
8) apt-get install ubuntu-gnome-desktop -y
9) vncserver -kill :1
10) vncserver
=============================
No comments:
Post a Comment