LINUX commands

useful linux commands

Posted by tfran on 2016-12-19 09:41:31

 

1. Set Static Ip from cli:

[root@tecmint ~]# ifconfig eth0 172.16.25.125 netmask 255.255.255.224 broadcast 172.16.25.63


2. Change root password:

      passwd root

 

3. You want to tar your files together and gzip the resulting tar file.

tar cvzf cvd.tar.gz cvd*.txt

    To untar the gzip'd tar file you would do:

tar xvzf cvd.tar.gz -C /path/to/parent/dir

This would extract your files under the /path/to/parent/dir directory

 

4. Command for ssh login from local without password

ls .ssh/authorized_keys

mkdir /root/.ssh

touch /root/.ssh/authorized_keys

cat /Users/telcovillage/.ssh/id_rsa.pub | ssh root@154.48.196.250 'cat >> .ssh/authorized_keys'

 

5. IPMI commands

ipmitool -H 154.48.196.166 -U ADMIN -E -I open bmc reset cold

 

6. Transfer

 rsync -avzhe ssh /home/vexim/omiridis.com/postmaster/Maildir/* root@154.48.196.185:/home/vexim/omiridis.com/postmaster/Maildir/

 

6. Check Inodes

root@all250:df -i
root@all250:/var/spool# for i in /var/spool/*; do echo $i; find $i -type f | wc -l ;done

7. The locale settings can be set (to en_US.UTF-8 in the example) as follows:

export LANGUAGE=en_US.UTF-8
export LANG=en_US.UTF-8
export LC_ALL=en_US.UTF-8
locale-gen en_US.UTF-8
dpkg-reconfigure locales

 

date +"%Y-%m-%d %H:%M:%S"

 

8. Generating locales
Missing locales are generated with locale-gen:

locale-gen en_US.UTF-8

Alternatively a locale file can be created manually with localedef:[1]

localedef -i en_US -f UTF-8 en_US.UTF-8

Setting Locale Settings
The locale settings can be set (to en_US.UTF-8 in the example) as follows:

export LANGUAGE=en_US.UTF-8

export LANG=en_US.UTF-8

export LC_ALL=en_US.UTF-8

locale-gen en_US.UTF-8

dpkg-reconfigure locales

For permanent use:

nano  /etc/environment

 

#LC_ALL="en_US.UTF-8"
#LANG="en_US.UTF-8"
#LANGUAGE="en_US:en"
LANGUAGE=en_US.UTF-8
LANG=en_US.UTF-8
LC_ALL=en_US.UTF-8

 

The dpkg-reconfigure locales command will open a dialog under Debian for selecting the desired locale. This dialog will not appear under Ubuntu. The Configure Locales in Ubuntu article shows how to find the information regarding Ubuntu.

 

9. Linux Commands

cat /etc/*-release

dmidecode --type 17 | grep Size

rm -rf /home/traces/voipHost4_*201511*.gz

find / -type f -size +100M

 

10 .Gzip / Gunzip

Multiple compressed files can be concatenated. In this case, gunzip will extract all members at once. For example:

      gzip -c file1 > foo.gz
      gzip -c file2 >> foo.gz

Then

      gunzip -c foo

is equivalent to

      cat file1 file2

In case of damage to one member of a .gz file, other members can still be recovered (if the damaged member is removed). However, you can get better compression by compressing all members at once:

 cat file1 file2 | gzip > foo.gz

compresses better than

  gzip -c file1 file2 > foo.gz

If you want to recompress concatenated files to get better compression, do:

  gzip -cd old.gz | gzip > new.gz

If a compressed file consists of several members, the uncompressed size and CRC reported by the --list option applies to the last member only. If you need the uncompressed size for all members, you can use:
    

  gzip -cd file.gz | wc -c

If you wish to create a single archive file with multiple members so that members can later be extracted independently, use an archiver such as tar or zip. GNU tar supports the -z option to invoke gzip transparently. gzip is designed as a complement to tar, not as a replacement.

11 .Block Incoming Request From IP 1.2.3.4

The following command will drop any packet coming from the IP address 1.2.3.4:

/sbin/iptables -I INPUT -s {IP-HERE} -j DROP

/sbin/iptables -I INPUT -s 1.2.3.4 -j DROP

You can also specify an interface such as eth1 via which a packet was received:

/sbin/iptables -I INPUT -i {INTERFACE-NAME-HERE} -s {IP-HERE} -j DROP

/sbin/iptables -I INPUT -i eth1 -s 1.2.3.4 -j DROP

12 . Find and Gzip

find /lib/tb/toolpack/setup/12366/2.7/apps/tbsigtrace/IP_*.cap -mmin +28 -exec gzip -r {} ;

13 . Pcap find SMS

 gsm_map.address.digits == "639064424447"
 tcap.otid == d0:d0:22:32
 tcap.dtid == d0:d0:22:32
 tcap.otid == d0:d0:22:32 || tcap.dtid == d0:d0:22:32
 gsm_sms.tp-oa == "491776768676"
 gsm_sms.tp-oa == "306977721597"
 tcap.otid == d0:d0:22:bf
 tcap.dtid == d0:d0:22:bf
 gsm_sms.sms_text == "Votre clé de compte Yahoo est PJMDYHCZ"
 ctrl-M

 

tcap.otid == f0:20:12:87 || tcap.dtid == f0:20:12:87