jump to navigation

Quick Command Reference January 9, 2009

Posted by ModelR in Everything LINUX.
trackback

Get a dhcp address

sudo dhclient

List samba users

pdbedit -Lw
or
cat /etc/samba/smbpasswd

List process that are currently running
ps aux

Location of the groups file
/etc/group

Location of the passwords file
/etc/passwd

file permission settings
rwx
owner | group | other
***************************************
Best place to store Linux shell scripts that you create
/usr/local/bin

Add a user to a group
usermod -a -G mygroupname myusername

Check if a user already exists
grep <username> /etc/passwd

OR
id <username>

if your using it as a check in a script you can use this command so it doesn’t print anything on the screen:
egrep "^$username" /etc/passwd >/dev/null

Check if a user has a password
grep <username> /etc/shadow

The mv command can be used for moving or renaming files. To rename a file, you can use it like this:
$ mv file file2

List user groups
cat /etc/group

Changing ownership of a target directory etc.
chown [-R] [[user]][:group] target1 [[target2 ..]]
example
chown username:group change.txt

Remove a non-empty directory (use this command with caution)
rm -rf directory/

Copying files
cp <file> <destination>

Sed command -> for replacing text
The following command pipes the contents of /etc/hostname to the sed command
The sed command then replaces whatever in the file that has the name jeos-lamp with jeos-lamp2, then writes it to the file /etc/hostname
cat /etc/hostname | sed -e 's/jeos-lamp/jeos-lamp2/' > /etc/hostname2
OR
Use this version if you are creating a script
cat /etc/hosts | sed -e {'s/'$(hostname)'/'$newhost'/'} > /etc/hosts2

To find out what user you are logged in as
whoami

To find out your current directory location (print working directory)
pwd

To list files
ls

To list files one per line with the attributes
ls -la

To delete a file
rm <filename>

To fill in command prompts automatically (example is for adding a password to samba)
(echo $password; echo $password) | /usr/bin/smbpasswd -s -a $username

Advertisements

Comments»

No comments yet — be the first.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: