Archive

Posts Tagged ‘BackTrack 5’

How To Completely Remove User Account In Unix (Linux)

Czerwiec 28, 2012 Dodaj komentarz

How do I remove a user’s access from my server? How do I delete a user account under Linux operating systems?

You need to use the userdel command to delete a user account and related files from user account or use this perl script:

/#!/usr/bin/perl
use strict;
use warnings;
use Fcntl ':flock'; # import LOCK_* constants

if ($#ARGV != 0) {
print STDERR "Usage is $0 <user>\n";
exit (8);
}

my $user = $ARGV[0];

sub edit_file($)
{
my $file = shift;

open IN_FILE, "<$file" or
die("Could not open $file for input");

open OUT_FILE, ">$file.new" or
die("Could not open $file.new for output");

while (1) {
my $line = <IN_FILE>;
if (not defined($line)) {
last;
}
if ($line =~ /^$user/) {
next;
}
print OUT_FILE $line;
}
close (IN_FILE);
close (OUT_FILE);
unlink("$file.bak");
rename("$file", "$file.bak");
rename("$file.new", $file);
}

my @info = getpwnam($user);
if (@info == -1) {
die("No such user $user");
}

open PW_FILE, "</etc/passwd" or
die("Could not read /etc/passwd");

# Lock the file for the duration of the program
flock PW_FILE, LOCK_EX;

edit_file("/etc/group");
edit_file("/etc/shadow");

if ($info[7] eq "/home/$user") {
system("rm -rf /home/$user");
} else {
print "User has a non-standard home directory.\n";
print "Please remove manually.\n";
print "Directory = $info[7]\n";
}
print "User $user -- Deleted\n";

edit_file("/etc/passwd");

flock(PW_FILE,LOCK_UN);
close(PW_FILE);</p>

This script  must be run as root user.

Running the script


root@bt:~/src/perl# ./del_user_a.pl
Usage is ./del_user_a.pl <user>
root@bt:~/src/perl# ./del_user_a.pl wysocand

Running On BackTrack 5R2
perl_del_user

 

Source:

Kategorie:Back Track 5, Perl Tagi: ,

Update Back Track 5

Marzec 18, 2012 Dodaj komentarz

Update and upgrade your BT5 (R1) installation

apt-get update
apt-get dist-upgrade
apt-get install beef
reboot

Verify that you are running a 3.2.6 kernel:

name -an
Linux bt 3.2.6 #1 SMP Fri Feb 17 10:40:05 EST 2012 i686 GNU/Linux

Apt Commands

apt-get install Downloads and all of its dependencies, and installs or upgrades them.
apt-get remove [–purge] Removes and any packages that depend on it. –purge specifies that packages should be purged.
apt-get update Updates packages listings from the repo, should be run at least once a week.
apt-get upgrade Upgrades all currently installed packages with those updates available from the repo. should be run once a week.
apt-get dist-upgrade [-u] Similar to apt-get upgrade, except that dist-upgrade will install or remove packages to satisfy dependencies.
apt-cache search Searches packages and descriptions for .
apt-cache show Shows the full description of .
apt-cache showpkg > Shows a lot more detail about , and its relationships to other packages.
man apt Will give you more info on these commands as well as many that are in less common usage.

dpkg commands

dpkg -i Installs a package file; one that you downloaded manually, for example.
dpkg -c Lists the contents of a .deb file.
dpkg -I Extracts package information from a .deb file.
dpkg -r Removes an installed package named
dpkg -P Purges an installed package named . The difference between remove and purge is that while remove only deletes data and executables, purge also deletes all configuration files in addition.
dpkg -L Gives a listing of all the files installed by . See also dpkg -c for checking the contents of a .deb file.
dpkg -s Shows information on the installed package . See also apt-cache show for viewing package information in the Debian archive and dpkg -I for viewing package information extracted from a .deb file.
dpkg-reconfigure Reconfigures an installed package
man dpkg Will give you more info on these commands as well as many that are in less common usage.
Kategorie:Back Track 5 Tagi: