May 24

Linux: Testing a samba printing connection with smbclient

I had a case where our AIX system would not print to a Windows 7 print share. I wanted to test it from a Linux workstations. Here is a brief process:
1. sudo apt-get install smbclient
2. touch testing123.txt
3. smbclient //192.168.1.23/sharename -U sambauser -W mydomain -c “print testing123.txt” –debuglevel=10

The debuglevel was an important addition to the testing process to see exactly what was happening.

Category: Linux, Windows | Comments Off on Linux: Testing a samba printing connection with smbclient
March 28

Linux: Create 10 GB file instantly using dd

Make sure that you have enough free space on the partition

To find out how much is free you can use from command prompt:
df -h

The output will look like this:
Filesystem                   Size  Used Avail Use% Mounted on
/dev/hda2                453G  364G   67G  85% /
tmpfs                           7.8G  292M  7.6G   4% /dev/shm

This means that you have some 67 GB of unused space, so you can proceed with next command that will create 10 GB file:
dd if=/dev/zero of=myharddisk.img bs=1000 count=0 seek=$[1000*1000*10]

Caveats:

This trick will work on ext3, ext4 & reiserfs – but will NOT work on FAT32 partitions as they have maximum file size of 4 GiB.

Also because this file is null from within – some programs will fail working with it – such as mkswapfs & mkswapon. For absolute majority of utilities it will work.

By: A. Eremenko

Category: Linux | Comments Off on Linux: Create 10 GB file instantly using dd
March 14

Linux: bash/sed delete the first and last lines of a group of files

When wanting to clean up some files for testing I needed to remove code from the front and end of the file in order to focus on the information in the body of the file.
The below commands are great when cleaning up files that have header and footer information that is similar in each file.

The following example shows how to delete the first 200 lines of a file:
find -type f -name ‘*.html’ -exec sed -i -e 1,200d {} \;

The following example shows how to delete the last 155 lines of a file:
find -type f -name ‘*.html’ -exec sed -i -e :a -e ‘$d;N;2,155ba’ -e ‘P;D’ {} \;

By: Tim Conrad

Category: Linux | Comments Off on Linux: bash/sed delete the first and last lines of a group of files
March 9

Linux: nohup – Keep an application running after you terminate your remote session

nohup is the perfect command line program to keep your applications running in the backgroup even when when you terminate your connection.
Example:
1. ssh into your server
2. type: nohup “the name of your long running application” &
3. exit

NOHUP(1) User Commands NOHUP(1)

NAME
nohup – run a command immune to hangups, with output to a non-tty

SYNOPSIS
nohup COMMAND [ARG]…
nohup OPTION

DESCRIPTION
Run COMMAND, ignoring hangup signals.

–help display this help and exit

–version
output version information and exit

If standard input is a terminal, redirect it from an unreadable file. If standard
output is a terminal, append output to ‘nohup.out’ if possible, ‘$HOME/nohup.out’
otherwise. If standard error is a terminal, redirect it to standard output. To
save output to FILE, use ‘nohup COMMAND > FILE’.

NOTE: your shell may have its own version of nohup, which usually supersedes the
version described here. Please refer to your shell’s documentation for details
about the options it supports.

AUTHOR
Written by Jim Meyering.

REPORTING BUGS
GNU coreutils online help: <http://www.gnu.org/software/coreutils/>
Report nohup translation bugs to <http://translationproject.org/team/>

COPYRIGHT
Copyright © 2016 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3
or later <http://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it. There is NO WAR‐
RANTY, to the extent permitted by law.

SEE ALSO
Full documentation at: <http://www.gnu.org/software/coreutils/nohup>
or available locally via: info ‘(coreutils) nohup invocation’

GNU coreutils 8.25 February 2016 NOHUP(1)

Category: Linux | Comments Off on Linux: nohup – Keep an application running after you terminate your remote session