Linux Commands

Everyday Linux Administration Commands

Linux: User and Group Management Commands




Command Description
useradd -m -c "Users name" userid Create a new user with a default home are of /home/userid
usermod -g new_primary_group userid Change primary group of a user
usermod -G group1,group2 userid Change group membership of a user. Separate groups with a comma.
usermod -d new_directory_path userid Change a users home area
usermod -s Specify shell userid Change the users shell to the specified shell. Must be full path: /bin/bash
userdel -r userid Remove userid and home directory of specified user from system
userdel userid Remove userid from system. Does not remove users home area
groupadd group Create New group
groupdel group Remove specified group
passwd -S userid Display status of userid specified
passwd userid change or set password for specified user. If no userid is passed, assumes current user
passwd -l userid Locks specified userid
passwd -u userid Unlocks specified userid
id userid Display user and group information
groups userid Display group membership for specified userid


Linux: Permission Commands


Command Description
chgrp group file Change group on file>
chown user:group file Change ownership of file file> to user:group
chmod + or - Change permissions + adds permission - removes r=read, w=write, x=execute
chmod 777 file Change permissions to rwxrwxrwx on file
chmod +x file Change file to be executable by Owner,Groups and others.
chmod -x file Remove execute permissions from file
chmod -R 640 /dir Recursively change permissions of directory dir and any files/directories contained within

Linux: Networking Commands


Command Description
ping host or IP Address Test for presence of a server on a network
dig domain Retrieve DNS information for specified domain
nslookup server Retrieve DNS information for specified server (hostname or IP address accepted)
traceroute hostname or IP address Trace route to specified server.
netstat --tcp Display Active Internet connections
wget file Download specified file. File can be a full path to a http address or an ftp site.
ip a s Display IP address information
iwconfig Display wireless adaptor information
ifconfig -a Display all network interfaces
ifup interface Activate interface
ifdown interface Deactivate interface
service network restart Restart network service
service network status Display network service status

Linux: Compression Commands


Command Description
tar cvf your.tar files Create a tar file called your.tar comprising of files
tar xvf your.tar Extract files from your.tar
tar tvf your.tar View contents of files in your.tar
tar czf your.tar.gz files Create a compressed tar file with Gunzip
tar xzf your.tar.gz Extract files from compressed archive
tar cjf your.tar.bz2 Create a compressed archive file with bzip2
tar xjf your.tar.bz2 Extract files from compressed archive
gzip file Compress file and rename to file.gz
gzip -d file.gz Decompress file.gz back to file

Linux: Secure Shell Commands


Command Description
ssh user@host Connect securely to host with user
ssh -p port user@host Connect securely to host with user on port port
ssh-copy-id -i identity_file user@host Install your Public Key to remote servers authorized_keys file
ssh -X -luserid IP or Hostname Connect to a server and forward the X server calls to the client computer. (For running GUI apps remotely)
ssh-keygen -t dsa or rsa Create authentication keys of type rsa or dsa
scp local_file user@host:/tmp Securely copy local file local_file to /tmp directory on server host with user user