Tagged: linux

How to get a previous date in bash (linux) 0

How to get a previous date in bash (linux)

Simply put

date -d '1 day ago' +'%Y-%m-%d'
# For multiple days
date -d '7 days ago' +'%Y-%m-%d'

If you wish to place in a shell script:

RMDATE=$(date -d '7 days ago' +'%Y_%m_%d')

will place for example ‘2013-07-01’ in the RMDATE variable which of course you can use like

echo $RMDATE

 

How to find physical location of /dev/sd* drives in linux 0

How to find physical location of /dev/sd* drives in linux

I wrote a lil script to help out with this.. The syntax is as follows:

finddrive.py sda

How this works is by lighting up the corresponding drive on the front panel for about 3 seconds.

#!/bin/sh

cmd="dd if=/dev/$1 of=/dev/null"
seconds=3

echo "Check front panel for indicator light"
$cmd&

cmdpid=$!
sleep $seconds

if [ -d /proc/$cmdpid ]
then
  # echo "terminating program PID:$cmdpid"
  kill $cmdpid
fi

Credits:  Fabio’s Blog

 

How to change date and timezone in linux 0

How to change date and timezone in linux

To change date:

date -s "18 JUN 2013 12:22:00"

To change timezone:

sudo dpkg-reconfigure tzdata

 

NOTE: After changing linux date/time/timezone make sure you restart cron with:

/etc/init.d/cron stop
/etc/init.d/cron start

#or in Ubuntu/Debian based OS's

service cron stop
service cron start

 

How to Connect to linux PC Via RDP 0

How to Connect to linux PC Via RDP

To use windows Remote Desktop Connection to connect to a linux pc. Simply install xrdp on the linux pc.

sudo apt-get install xrdp

Thats it! Youre done!

If for any reason you encounter any problems.. the solution is supposedly either

echo "gnome-session --session=ubuntu-2d" > ~/.xsession

or

sudo apt-get install gnome-session-fallback

 

How to mount drive as read only on linux 0

How to mount drive as read only on linux

You normally have to do this when you are dual booting and your windows partition is in a state of hibernation.. Linux sees this and refuses to touch files

Complicated Linux Suggested Method:

sudo mount -t "ntfs" -ro "uhelper=udisks2,nodev,nosuid,uid=1000,gid=1000,dmask=0077,fmask=0177" "/dev/sda2" "~/Desktop/D/"

Where ‘D’ is a folder you previously created to mount the drive (mkdir ~/Desktop/D)

If for some reason this doesnt work.. you can force delete the hibernation data by

mount -t ntfs-3g -o remove_hiberfile /dev/sda2 ~/Desktop/myplacetomount

 

How to mount samba share on linux using fstab 0

How to mount samba share on linux using fstab

# Debian/Ubuntu
apt-get install smbfs smbclient
# Fedora/Redhat
yum install smbfs samba-client #If not found try smbclient

mkdir /mnt/dirname
//fileserver/sharename /mnt/dirname smbfs username=root,password=mypass 0 0

NOTES:

How to find shares on a remote linux PC

smbclient -L jumbo -Uusername -I ip-address

How to manually mount fstab

mount -a