You are here

Linux

A simple way of restoring the content of deleted text files

Undeleting a file is not easy in Linux.
However, if it's a text file, and you know a phrase from it, you can search the whole drive for the contents:
```
grep -a -C 200 -F "words in file" /dev/hda1 | more #change /dev/hda1 to whatever is appropriate
```

Topic: 

Setting up NFS on Ubuntu 16.04

Make sure userid’s and groupid’s match between the systems

  • e.g. usermod -u 1001 -g 504 -c "Andrew Fountain" andrewf

Set up the server

  • set up the fully qualified domain name, e.g. server.example.org
vi /etc/hosts         # ensure it contains the line: 127.0.1.1 server.example.org
vi /etc/idmapd.conf   # ensure it contains the line: Domain = example.org (not the name of the server but the domain)
hostnamectl set-hostname server.example.org
#pre sytemed edit /etc/hostname manually, and also run hostname server.example.org
Topic: 

SMART monitoring of USB drives on Linux

using smartmontools documentation, try:

smartctl -d sat,16 -i /dev/sdc # find if enabled
smartctl -d sat,16 -a /dev/sdc # display all info

more documentation:

Topic: 

umount - device is busy

I you get “device is busy” when running umount, try

sudo lsof | grep /dev/xxxx
# or
sudo fuser -cu /dev/xxxx
Topic: 

Upgrading CentOS 6 to PHP 5.4 (or 5.5)

  • SCL is the way to go since it has RedHat’s blessing

Note that it is the .conf file that controls which version of php is used. For some reason this does not seem to be available for php55. It is possible that anther package needs to be installed, containing libphp5.so.

Creating a startup script

#!/bin/bash
### BEGIN INIT INFO
# Provides:          mystartup
# Required-Start:    $all
# Required-Stop:     $remote_fs $syslog
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Enable Wine 16bit support
# Description:       Fix recommended by Linus to enable Wine 16bit support
### END INIT INFO
echo 1 > /proc/sys/abi/ldt16
  • Then activate with:
Topic: 

Setting up X2GO

Install on Ubuntu server

add-apt-repository ppa:x2go/stable
apt-get update
apt-get install x2goserver x2goserver-xsession
apt-get install python-software-properties
apt-get install x2godesktopsharing
  • For Ubuntu 14:10, edit /etc/apt/sources.list.d/x2go-stable-utopic.list and replace trusty with utopic
Topic: 

Setting up NFS4 on CentOS

First: install server software and start it

yum install nfs-utils nfs-utils-lib system-config-nfs
yum install nfs-utils nfs4-acl-tools portmap
chkconfig nfs on
chkconfig portmap on
service nfs start
echo 'portmap:ALL' >> /etc/hosts.deny
echo 'portmap:192.168.1.0/24' >> /etc/hosts.allow
service portmap start

run the firewall gui and turn on NFS4 (2049)

Topic: 

SSDs with Linux

Here are some good recommendations:

Topic: 

Creating a server share using sshfs

  • Modify /etc/fuse.conf to uncomment the line: user_allow_other
  • Add the user to the fuse group:
adduser $USER fuse
  • relogin to get access

Connecting interactively:

sshfs -o allow_other,umask=117,uid=1002,gid=1002 myname@sv:/home/common /home/myname/common
  • allow_other # not needed here unless others can connect through this mount
  • umask=117,uid=1002,gid=1002 # controls how the files appear to this computer. If no uid or gid then the process that invokes the command will own it

Connecting through fstab

  • Note that it is best to connect on demand in case the network is not up when fstab runs originally
  • Four steps are required:
  1. Add user to fuse group
    • See above
  2. Insert entry into fstab of client computer
myname@sv:/home/common  /home/myname/common fuse.sshfs users,_netdev,noauto,x-systemd.automount,reconnect,allow_other,workaround=rename,umask=117,uid=1002,gid=1002 0 0
  • noauto # does not immidiately mount
  • x-systemd.automount # manually connects on demand if using systemd (not upstart)
  • workaround=rename # gets rid of some problems
  • _netdev # don’t try if no network
  • default_permissions # lets kernel check permissions—seems to conflict with setting uid/gid
  • reconnect # reconnect to server
  • users # not documented anywhere, but needed to allow users other than root to activate
  • Need to reboot system to get mountpoints activated
  1. Mount shares on logon
    • Can place a mount script in ./kde/Autostart e.g.
#!/bin/bash
# must already be in /etc/fstab
mount ~/common
mount ~/personal
  1. Enable password-less logon
    • See here: /how-create-password-less-ssh-login
    • Don’t forget to make sure server home directory is as least as secure as 750
Topic: 

Pages

Subscribe to RSS - Linux