Clemson University School of Computing Logo

IT Support

Linux Tips

The Linux command line

The Linux command line is a very useful and powerful tool; it's where you'll be spending much of your time as a computer scientist, at least while you're at Clemson. To enter the Linux command line, you will need to use the Terminal or Terminal Emulator application (under the System menu).

Here are some basic Linux commands that might be useful. An extended list can be found on the Linux Cheat Sheet.
  • pwd - show current directory
  • ls - displays files/directories
  • cd - change directory
  • mkdir - create a directory
  • rmdir - delete directory
  • cat - display contents of a file
  • cp - create a copy of a file
  • mv - rename or move a file
  • rm - remove a file

Command line aliasing

In Linux, aliasing can be used to create shortcuts for lengthy commands or change the behavior of default commands. Here are a few handy aliases that will help prevent deleting/overwriting files. The '-i' flag triggers a prompt to confirm the operation.

  • alias rm='rm -i'
  • alias cp='cp -i'
  • alias mv='mv -i'

To make these aliases permanent, they can be put into the .bashrc file in your home directory. For example, the default .bashrc for the SoC is shown below.

# This file is sourced for interactive bash shells.  Here are some examples of
# an interactive shell being invoked:
#   ssh user@host some-command
#   bash
#   su username
# However, it is typical (and the default) to source this file in
# ~/.bash_profile, in which case this file is sourced for all interactive and
# login shells.
# Defining aliases or functions is typically done in this file.  Exporting
# variables is usually better suited for ~/.bash_profile.
# WARNING: It is NOT safe for commands in this file to generate output.  Things
# like sftp and scp will break.
# Some sane defaults are set by the Clemson School of Computing staff.  Feel
# free to change or remove them.

# Set the prompt.
PS1='[\t] \u@\h:\w [\#] '

# Keep all of your files not readable or writable by others.  If you commonly
# work in group directories you may want to change this to 026 or 006.
umask 066

# Prevent files from being overwritten by redirection.
set -o noclobber

# Prompt before removing or overwriting files with common commands.
alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'

# Common shortcuts for ls.
alias ls='ls --color=auto'
alias la='ls -a'
alias ll='ls -l'
alias lla='ls -la'
# Common misspellings for ls.  Uncomment if you want them.
#alias sl="ls"
#alias LS="ls"

Remote access to other Linux systems

SSH, the Secure Shell, can be used to gain access to remote Linux systems. A remote system that you will want to become familiar with as a student in the School of Computing is

SSH lets you run programs on a remote system. You can also transfer files to and from a remote system. An easy way to do this is to use the FileZilla program (located in the Internet menu).

Compiling C programs

Even if you don't yet know how to write C code, let's go ahead and demonstrate how to compile and run a C program. For this, download the sample Hello World C program using a browser in your Linux virtual machine, and save the file somewhere in your home directory. Now use the command line to navigate to where you saved the file.

C files are just text files. The computer doesn't know how to run them directly, so you first have to compile the file. This process reads your C file and creates a new file which your computer can run.

To compile hello.c, use the following command:

gcc -Wall -o hello hello.c

This will create a file named hello. This file is a program, and it can be run by typing in this command:


Any time you modify your C code you must re-compile the code by running the same gcc command again, otherwise the program won't change!