Tuesday, September 13, 2011

Useful Linux Commands

I recently had to move a server and needed to set up another server.  I'm a linux newbie so I needed to look up a  lot of things.  Below are some of the more common commands that I needed:  (replace <content> with your own command/name).

Create a short name or alias to run a command.
alias <aliasname>='<somecommand>'

Create a symbolic link to another directory/file
ln -s <source> <target>
http://kb.iu.edu/data/abbe.html

Transfer files from your computer to a server or from a server to another server.
scp <somefile> <username@foobar.com>:</somefileordir>
scp <username@foobar.com>: <username2@foobar2.com>:</somefileordir>

Change file owner w/ recursion
chown -R <user>:<group>

Change file permissions for web w/ recursion
chmod -R 644 <somefileordir>

Find a file
find / -name <foo>
http://content.hccfl.edu/pollock/unix/findcmd.htm

Add a user
sudo useradd -d /home/<testuser> -m <testuser>
sudo passwd <testuser>

Change a users' primary group
usermod -g <newgroup> <user>

Add a group
groupadd <newgroup>

Add a user to a group
usermod -G <newgroup> <user>

No comments:

Post a Comment