Showing posts with label Linux. Show all posts
Showing posts with label Linux. Show all posts

tar, tz, gz

Posted on by Kim


.tar.gz

Compress

tar -zcf folder.tar.gz folder

Decompress

tar -xzf [your-tar-file.tar.gz]


Split

split -b 1000M enterprise-search-8.0.0-beta1.tar enterprise-search-8.0.0-beta1.tar.part

Join

cat enterprise-search-8.0.0-beta1.tar.part* > enterprise-search-8.0.0-beta1.tar.part

Other

If a file ends in .zip (for example, file.zip) type:
unzip file.zip

If a file ends in .tar (e.g., file.tar) type:
tar -xvf file.tar

If a file ends in .gz (for example, file.gz) type:
gzip -d file.gz

If a file ends in .tar.gz (e.g. file.tar.gz) type:
gzip -d file.tar.gz
and then
tar -xvf file.tar

If a file ends in .tgz (e.g. file.tgz) type:
tar -xvzf file.tgz

Folder size in terminal

Posted on by Kim

sudo du -h -d 1 -h : human read -d : depth

Change the ll command

Posted on by Kim

add to .bashrc

alias ll='ls -la --color=auto'

Change password expiry in Linux

Posted on by Kim

“chage” is the command to list & change the password aging information for Linux user account. The chage command changes the number of days between password expiry and the current date. Here’s a real quick on how to show the expiration date of a particular linux user account.

Listing password aging for user:

chage command with option -l shows the password expiry details of a user. In this example, the user’s last password change was on Dec 25th 2017 and it expires in 90 days. The user will be notified within login 7 days before expiry.
 [root@centos01 ~]# chage -l demouser
 Last password change : Dec 25, 2017
 Password expires : never
 Password inactive : never
 Account expires : never
 Minimum number of days between password change : 0
 Maximum number of days between password change : 90
 Number of days of warning before password expires : 7
 [root@centos01 ~]#

Change the number of days to expire:

Use -M option and provide the number of days for expiry.
 [root@centos01 ~]# chage -M 120 demouser
 [root@centos01 ~]# chage -l demouser
 Last password change : Jan 25, 2018
 Password expires : May 25, 2018
 Password inactive : never
 Account expires : never
 Minimum number of days between password change : 0
 Maximum number of days between password change : 120
 Number of days of warning before password expires : 7
 [root@centos01 ~]#

Change the password to never expire:

You can use chage to make the password never expire with the below options. This sets password and the account to never expire.
 [root@centos01 ~]# chage -m 0 -M 99999 -I -1 -E -1 demouser
 [root@centos01 ~]# chage -l demouser
 Last password change : Jan 25, 2018
 Password expires : never
 Password inactive : never
 Account expires : never
 Minimum number of days between password change : 0
 Maximum number of days between password change : 99999
 Number of days of warning before password expires : 7
 [root@centos01 ~]#

Change account expiry to specific date:

You can set the account to expire on specific day or +N number of days from the current date. Here are the examples using chage -E option.
[root@dev01 ~]# chage -E 2019-05-12 demouser
or
[root@dev01 ~]# chage -E $(date -d +180days +%Y-%m-%d) demouser
[root@dev01 ~]# chage -l demouser
Last password change : never
Password expires : never
Password inactive : never
Account expires : May 12, 2019
Minimum number of days between password change : 0
Maximum number of days between password change : 99999
Number of days of warning before password expires : 7
[root@dev01 ~]#

Shortcuts to servers

Posted on by Kim

vi ~/.ssh/config

Host jenkins
    Hostname 198.234.12.434
    User geaddev

Host test
    Hostname v-x-e-4ewf.edfer.facb
    User geaddev

vi ~/.bash_aliases
alias jenkins='ssh jenkins'
alias tst='ssh test'
alias sta='ssh staging'

Add key to server
ssh-copy-id -i ~/.ssh/id_rsa.pub tst
Change color
alias sta="printf %b '\e]11;#FDA50F\a' && ssh staging"
alias prod="printf %b '\e]11;#770000\a' && ssh prod"

How to remove "Permission denied" with find

Posted on by Kim

Add

2>&1 | grep -v "Permission denied"

after the normal find. Eg.

find / -name domain.xml 2>&1 | grep -v "Permission denied"

less - How to use

Posted on by Kim

less <filename>

Shift f : Like tail -f
Ctrl c : Break tail

Ctrl b : Go one page back
Ctrl f : Go one page forward

/ : Search forward
? : Search back
n : Next search i search

g : Go to top
Shift g : Go to buttom

Virtualbox stopping at spawning session 0%

Posted on by Kim

Trying to start Virtualbox I got this: spawning session 0% and it never grows.

sudo /etc/init.d/vboxdrv setup

Fixed it.

How to make Citrix Client run on Linux

Posted on by Kim

First need a Client witch can be found here: Linux ICA Clients

Unzip and run setupwfc. I selected /usr/lib/ICAClient as install dir.

If getting the fowling error: You have not chosen to trust “Thawte Server CA”, the issuer of the server’s security cerfiticate (SSL error 61) you need to copy the certificates to the client E.g.

sudo cp /usr/share/ca-certificates/mozilla/* /usr/lib/ICAClient/linuxx86/keystore/cacerts/

Get DNS name from IP

Posted on by Kim

To get the DNS name from the IP just use nslookup :)
E.g.

kim@X151023:~$ ping google.com
PING google.com (64.233.187.99) 56(84) bytes of data.
64 bytes from jc-in-f99.google.com (64.233.187.99): icmp_seq=1 ttl=239 time=116 ms

--- google.com ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 1999ms
rtt min/avg/max/mdev = 111.008/113.074/116.091/2.215 ms
kim@X151023:~$ nslookup 64.233.187.99
Server:  10.17.3.7
Address: 10.17.3.7#53

Non-authoritative answer:
99.187.233.64.in-addr.arpa name = jc-in-f99.google.com.

Authoritative answers can be found from:

kim@X151023:~$

Remote Desktop for Linux

Posted on by Kim

Remote Desktop from linux.

rdesktop <IP> -u <USER> -g 1600x1200

Mount windows drive in Ubuntu

Posted on by Kim

sudo fdisk -l

Disk /dev/sda: 120.0 GB, 120034123776 bytes
255 heads, 63 sectors/track, 14593 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x91f391f3

Device Boot Start End Blocks Id System
/dev/sda1 * 1 7153 57456441 7 HPFS/NTFS
/dev/sda2 7154 14593 59761800 5 Extended
/dev/sda5 7154 14284 57279726 83 Linux
/dev/sda6 14285 14593 2482011 82 Linux swap / Solaris

cd /mnt/
sudo mkdir windrive
sudo mount -t ntfs /dev/sda1 /mnt/windrive -o "umask=022″

Enable .htaccess in apache2

Posted on by Kim

Go to /etc/apache2/sites-available
sudo vi default
Change 'AllowOverride None' to 'AllowOverride All'

and restart:
sudo /etc/init.d/apache2 restart



Note: Should be done by:
add new entry in /etc/apache2/sites-available and
Add by:
sudo a2ensite [name] // Means that there will be a new link in /etc/apache2/sites-enabled

Remove by:
sudo a2dissite [name]