Web Resources  >  Unix Commands

Useful Unix Admin & Networking Commands

hostname
Prints the name of the current host system.

ls useful options

  • "ls -F" appends a forward slash to the subdirectory names so you can easily distinguish them from file names.
  • "ls -a" it will show all "hidden files".
  • "ls -l" it will show detailed information about each file and directory, including permissions, ownership, file size, and when the file was last modified.
  • "ls -d" If an argument is a directory, lists only its name (not its contents); often used with -l to get the status of a directory.

 

netstat
Displays a list of active sockets for each protocol.
netstat -an | grep 80 searches for port 80.

top
Top displays the top 15 processes on the system and periodically updates this information.

ps
The ps command prints information about active processes. Without options, ps prints information about processes that have the same effective user ID and the same controlling terminal as the invoker.
Use 'ps -ae' to display all the processes. To search if a particular process is running; for e.g. to see if telnet is running, run 'ps -ae | grep telnet'.

SCP
The OpenSSH Secure Copy (SCP) is a secure replacements for the CP commmand. Here is how you run.
To scp local files to a different machine,
cd /source_machine/directory/
scp localfilesuserame@DestinationHost.com:/path/to/upload
In this example, your files are located on the client machine in /source_machine/directory/, you want to upload them to /path/to/upload. So to break this command down we have a few sections:

  • scp - The command itself
  • localfiles - The file or files you want to upload
  • userame@DestinationHost.com - the username and the destination host address.
  • :/path/to/upload - The path on the server to upload the files.

 

SSH
Secure Shell (SSH) is often used as a stealthy alternative to TELNET. You can read more about SSH here. If SSH is running on the remote machine on a different port, use the following command to login to a remote host via ssh:
ssh -p portNumber remoteUserName@DestinationHost

Rsync
rsync is an open source utility that provides fast incremental file transfer. It is a better alternative to scp. SCP copies all the files, rsync only copies the files that has changed.
To first do a dry run to see what would have transferred, run the following:
rsync -nav --progress --stats --rsh=ssh directoryToSync mailto:remoteUserName@DestinationRemoteHost:%7E/RemoteHostDirectory/ 

  • "rsync" means "run the rsync program"
  • "-a" means "Backup all sub-directories maintaining all permissions, groups, users, times, and devices."
  • the "v" after the "a" means "Be more verbose. Tell me more about what's going on."
  • the "n" after the "v" means "Don't actually do anything, just tell me what you're going to do.
  • the "--progress" means "Give me progress updates while you're backing things up."
  • the "--stats" means "Let me know exactly what you did after it's all done."

Now to actually sync, run the following command, which is the same command, but without the n option:
rsync -av --progress --stats --rsh=ssh directoryToSync remoteUserName@DestinationRemoteHost:~/RemoteHostDirectory/

RPM
The RPM Package Manager (RPM) is a powerful command line driven package management system capable of installing, uninstalling, verifying, querying, and updating computer software packages. To find your own RPM package, visit http://rpmfind.net/linux/RPM/. Here is how to use the command:

  • Install an RPM: rpm -i file.rpm
  • Remove an RPM: rpm -e name_of_rpm.rpm.
  • Upgrade an RPM: rpm -Uvh rpmname.rpm
  • List all rpms in the system: rpm -qa
  • List all files in an installed rpm: rpm -ql rpmname
  • List all the files in an rpm file that has not been installed on your system: rpm -qp rpmname.rpm -ql
  • Find out which rpm does the specified file belong to: rpm -q --whatprovides `which `
Common options:

--test - mock install/remove/etc. Don't really do it, but see if it works.
-v --hash - draw a progress bar of the install/remove/etc
--force - force an installation (can really mess up the database)
--nodeps - Don't check for dependencies (can really mess up the database)

Recursive grep on files

find . -type f -print | xargs grep -i [PATTERN]

Exceptional Customer Service
Click here to see our extensive Alaska Web Designers portfolio! Webdesign companies provide services to many Alaska firms. Choose Alaska Web Designers to serve your company today. All of our Alaska Web Designers are professionally trained and stay current with latest website business techniques. Portfolio
Check out our extensive portfolio!
We specialize in: Web Design, Web Development, E-Commerce Integration, SEO Internet Marketing, Database Design and Software Development!
Click here to see how our Alaska Web Designers do business in Anchorage, Alaska. Good website developers offer clients value, thus making their companies more productive Our Process
Come see how our business works!
Our business process can and will save your company time and money!
We are your #1 Web Design choice in Alaska! Good service for your firm is our mission. Alaska Web Designers are available to serve your business needs. Web Design
Check out our Web design services!
We specialize in Web design. We can improve your company's presence on the Web.
We are your #1 Web Development choice in Alaska! Web Development
We build applications for the Web
We specialize in Web 2.0 application development. Our professional software engineers can make the Web application of your dreams.
Click here to see our e-commerce solutions for your company! Alaska Web Designers should always be providing value to your firm. Choose Alaska Web Designers to make your e-commerce run smoothly. E-Commerce
We can move your business onto the Web!
Let our software engineers optimize your sales potential. With our E-Commerce solutions your company can make sales 24-7!
Click here to see our Internet Marketing solutions and SEO packages! Our Alaska Web Designers are trained in SEO strategies to propel your firm to the top. Let Alaska Web Designers serve your business needs. Internet Marketing
Improve your company's marketability on the Web!
We can create a marketing plan that will improve your search engine ranking and get your company the reputation it deserves!

NWDS Alaska Web Design Company's webdesign offers affordable custom website design. Our full service website design company only hires formally trained website designers. Please contact us today at 907.227.1676 or chowell@nwds-ak.com for your next web site design project.

Web Site Map