Beruflich Dokumente
Kultur Dokumente
Directory Commands
pwd “Print Working Directory” Display the name of the current working
directory
cd Change working directory back to home directory
cd /dir1/subdir Change working directory using absolute path
cd subdir Change working directory using relative paths (does not start with “/”)
cd .. Go back one directory level
mkdir dirname Creates a new directory with the name “dirname”.
rmdir dirname Removes or deletes the “empty” directory “dirname”.
rmdir –r dirname “Recursively” removes or deletes the directory “dirname” and EVERYTHING below it.
Use with EXTREME caution!
File Commands
- The -i option is not critical to the following commands but it provides an interactive "are you
sure?" prior to execution.
Examples:
grep is useful in searching for specific “strings” in file names or file contents.
Examples:
grep rpg /etc/hosts Show all occurrences of “rpg” in the file “hosts” in the /etc
directory.
ls /etc | grep host* List the /etc directory, only returning filenames beginning with
“host”.
Ownerships and permissions
The format of permission groups is: owner/group/others. The format of the permissions within each
segment is read/write/execute. This can be shown using the “ll” or “long list” command in the
illustration below.
The first far left column in the illustration shows the type of file. For example, “Desktop” is a directory,
shown by the letter “d”. All others (with the “-“) are “regular” files.
The next 9 columns show the file permissions. 3 each for “owner”, “group” and “others” from left to
right.
Examples:
“install.log” looks like “-rw-r--r--“ First of all, it is NOT a directory (it has a dash in the first position).
The permissions are: “rw-” for “owner”. “r--” for “group” and “r--” for “others”. A dash “-“ indicates the
permission is not set.
“Desktop” IS a directory and has permissions of: “rwx” for “owner”, “r-x” for “group” and “r-x” for others.
Skip over a column or two, and you will see the “owner” name and “group” name associated with that
file or directory. In this case, root is the owner of everything in this directory and only users in the group
“root” have access to these files.
chown user:group filename Changes ownership of the file “filename” to the username “user” and
groupname “group”.
chmod g +x filename Modifies a files permissions. In this case, we are setting the
executable (x) flag to true (+) in the group (g) field.
chmod 744 filename Similar to above. Modifies the permissions of the file “filename” using
an octal format. In this case the owner has full (read/write/execute)
permissions, with group and others having only read permissions.
Process Commands
ps -ef List the status of current process (or running programs) and its process
identification (PID):
ps -ef | grep user_id List current process status and PID for a certain user:
ps -fu user_id Gives the same result as above
pstree Lists processes in an orderly “tree” format.
kill PID Kill (or terminate) a process:
kill -9 PID Stop an unresponsive process:
NOTE: Use this command very carefully! It can have a drastic impact on your system. The kill PID
command is a better choice for terminating a process.
top Lists the top CPU resource users: (q to quit)
Miscellaneous Commands
su {password} Become the “Super User” (root). (Some also call it “Switch User)
su - {password} Become the “Super User” (root) and assume root’s environment (paths,
home directory, etc)
whoami Determine who you are logged in as: (effective user)
who am i Determine who you are logged in as: (who you really are, real user)
who –r Shows the current init state or run level
clear Clear screen
exit Exits the window or shell:
which command Determine the full path of a command or alias
df -hT Shows mounted file systems, associated mountpoints and file system types
mount /filesystem /mountpoint Mounts a file system to a target directory (mountpoint)
umount /mountpoint Unmounts a previously mounted filesystem (use df –hT to find
mountpoints and to print file system type)
man command Displays the manual (help) pages for command
man man Displays help on using the man command
Switch
sho vlan brie Show vlans in brief format. NOTE: VLAN 2 acts as a separate switch.
Switch & Router
en {password} Turn on (enable) privileged commands
disable Turn off privileged commands
sho int Show status of all interfaces (except aux and con).
sho int fastethernet #/# Shows status of specific interface #/#.
sho run {priv} Show running configuration
sho mac-address-table Show mac to port associations
sho arp Show “arp” IP to physical address.
sho ip int brie Shows a brief summary status of IP interfaces
exit Log out of device