Edward Parrish © 2003     

Use the Linux Command Line

On This Page


Introducing the Linux Command Line

  • Linux command line available from the Terminal emulation program
  • Terminal emulation program

  • Single-click the above icon on the launch panel (taskbar)
  • Alternatively, you can launch from the Main Menu
    Programs => System => GNOME terminal
  • Once you have a command line, you can use the UNIX help facility:
    man commandName
  • For example, to view the man(ual) page for the cat command:
  • man cat
    
  • To quit viewing a man page, press the q (for quit) key

Navigating Directories

  • When the terminal is first opened, you are located in your home directory:
    /home/cis164
  • You can verify the location using pwd (print working directory)
  • pwd
  • You can list the files in the current directory using ls
  • ls
  • View a file using any of the commands: cat, more or less
  • cat exercise2.txt
  • Change up one directory level: cd .. (change directory)
  • cd ..
  • Change to a subdirectory level: cd filename
  • cd cis164
  • Change to the root of the file system: cd /
  • cd /
  • Change to any location in the file system: cd path
  • cd /home
  • Change to your home directory cd ~
  • cd ~

Administering Users and Groups

User Accounts and the Superuser

  • Security in Linux is controlled with user accounts, just like Windows
  • Each account has a login and password
  • One user, known as the superuser, can do anything in the system -- even destroy it
  • The account name for the superuser is "root"
  • Normally, one should not log in as root
  • The root login is strictly for configuration and administration of a system
  • Sometimes need to switch temporarily to the root account
  • Use su (switch user) command
  • su -l root
  • When finished as the superuser, use the exit command
  • exit

File Ownership

  • Every file and directory has an owner
    • Default owner is root
  • Owner of the file grants permission to other users to read, modify, delete, or execute it
  • Owner can decide that no other users should be granted access to a file
    • The exception is the superuser
    • A user cannot take away access from the superuser
  • Owner (or root) can change ownership of a file or directory
  • Type chown newOwner filename where:
    • newOwner is the username you want to change ownership to
    • filename is the name of the file or directory
    chown root myfile.txt

Groups and Belonging

  • Every user belongs to one or more groups
  • Default group is users
  • Every file and directory also has a group owner
  • One can see the individual and groups by using the ls -l command
  • ls -l
  • Owners (or root) can change the group of a file or directory
  • Type chgrp newGroup filename where:
    • newGroup is the group you want to change ownership to
    • filename is the name of the file or directory
    chgrp mysql myfile.txt
  • The superuser can add users to additional groups
  • Type useradd -g newGroup userName where:
    • newGroup is the group you want to add to the user
    • userName is the users account name
    useradd -g mysql cis164

More Information


Using File Permissions

  • One can see file permissions using the ls -l command
  • First digit is the file type
  • Next 3 digits are the Owner permissions
  • Next 3 digits are the Group permissions
  • Next 3 digits are the Others (everyone) permissions
  • If a permission is missing for an owner, group of other, it is represented by - (dash)
  • File permissions are altered with the chmod command followed by octal value for each user type and the filename, where:
    • Read = 4
    • Write = 2
    • Execute = 1
  • For example:
  • chmod 755 exercise2.txt
  • Above example gives full permission for the owner, read and execute access for the group and others

More Information


Home | WebCT | Announcements | Schedule | Expectations | Syllabus
| Help | FAQ's | HowTo's | Links

Last Updated: 7/16/2003 4:45:47 PM