0% found this document useful (0 votes)
58 views

Linux Exercise

1. The document provides step-by-step instructions for using common Linux commands in both Windows and Linux environments. 2. The steps guide the user through logging in, opening a terminal, creating directories and files, editing files, changing file permissions, and sharing files before logging out. 3. Key commands introduced include mkdir, pwd, ls, cd, cat, rm, and chmod.

Uploaded by

amina souyah
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
58 views

Linux Exercise

1. The document provides step-by-step instructions for using common Linux commands in both Windows and Linux environments. 2. The steps guide the user through logging in, opening a terminal, creating directories and files, editing files, changing file permissions, and sharing files before logging out. 3. Key commands introduced include mkdir, pwd, ls, cd, cat, rm, and chmod.

Uploaded by

amina souyah
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Linux Exercise

The following steps will guide you through the most common Linux com-
mands. If you are using windows (Library and any Windows lab on cam-
pus), then start with step 1. If you are using a linux machine (Olin 170,
Dana 213, Brki 164), then start with step 3. (For access to Linux on your
own computer, please note the links on our webpage for windows and Mac
OS X.)

1. Log into Windows with:


Ctrl-Alt-Del → type in your username and your password
2. Start (left bottom) → All Programs → Xmanager Enterprise 3 →
Sessions → Linuxremote1 Graphical.
3. Log into a linux workstation. To do so type after login: your user-
name and hit “Enter” and after password: your password. Use the same
username and password as for your windows account at Bucknell.
4. With the cursor on the background click on the right mouse button and
choose “Open Terminal”. This should open a window in which you can
write commands.
5. Create a directory of the name “Capstone s2011” by typing in this new
window

mkdir Capstone s2011


and hit “Enter.” For all following commands hit “Enter” after each com-
mand. Draw the tree of the directories and files for this step and all the
following steps.
6. Check the directory name in which you are now by typing (print working
directory)

pwd
answer:
We call this directory (into which you get when you log in) your “home
directory”.
7. Check the contents of your current directory (list) with
ls
answer:
8. Change the current directory. Get into Capstone s2011

cd Capstone s2011
and redo 6.
9. Create a file with filename “linux logfile” by typing
nedit linux logfile &
or for larger font
nedit -font 10x20 linux logfile &
A new window will open up. NEdit is an editor, that means that you can
edit files with it (so like Word on windows). For a quick introduction to
NEdit click on the “Help,” located on the right of the menue bar on the
top. For more information see also the link on our webpage. In case you
are used to vi or any other editor, feel free to use it instead.
Write into the linux logfile:

Linux commands:
===============
mkdir create directory
pwd print current directory
ls list contents of current directory
Save the contents of the file with File → Save (or shorter Ctrl+S) and
quit the editor with File → Exit. You might want to use this file in
the future as a reference for linux commands. Add to it new commands
whenever you learn them.
10. In this course we will often want to share each others programs (files).
Since usually all your files are protected from being read by anyone else
but you, you will need to change this permission whenever you would like
other people (your classmates and me) to be able to read your file (see also
22. of this Intro). You do this in this example with:

chmod a+r linux logfile


“a” means “all” and “+r” means “add read permission”. With ls -l you
can check the permissions of any file and directory. The first three digits
specify your permissions, the last three digits specify the permissions of
everybody else. In each case the digits are for executable,reading and
writing. Change the reading and writing permissions of the linux logfile
and check after each change with
ls -l linux logfile

11. Check again the contents of the current directory.


answer:
12. Create another file called “tryfile” with content

hello
good bye
and redo 7.
13. Look at the contents of the tryfile with

cat tryfile

14. Do the same with the logfile.


15. Next remove (delete) the tryfile with

rm -i tryfile
You will be asked if you like to remove tryfile. Type y for yes. Check again
the contents of your current directory. rm is a dangerous command. It has
together with the wild card ’*’ the power of removing all your files in a
single command! Think always twice before you remove a file!
16. Create a directory with name “trydir”

mkdir trydir
and get into it with

cd trydir

17. Get back out of trydir (one step higher in the tree of directories) with

cd ..
Check in which directory you are.
18. Remove trydir with

rmdir trydir

19. Get back to your home directory either with

cd
or with

cd ~
or with

cd ~yourusername
(e.g. for me cd ~kvollmay). This gets you to anyone’s home directory.
20. Look at the contents of your linux logfile with

cat ~/Capstone s2011/linux logfile


We used here the full path of the linux logfile, so it would work from any
directory.
21. The following guides you through the steps you will need to “hand in”
any program assignment in the course. (A program, more precise “source
code,” is a file like the linux logfile.) The following three commands you
need to do only once
cd
mkdir share.dir
chmod 755 share.dir
Check with ls -l what the last command did. Then go to the directory
where your assigned program is, e.g.
cd ~/Capstone s2011/
Then copy the file you want to have accessible, e.g.
cp linux logfile ~/share.dir/
chmod a+r ~/share.dir/*
The asterik means that you changed the permission of all files and direc-
tories in ˜/share.dir/.
22. For logging out of your linux session:
22a. For Windows: Click on “System” which is located at the menue
bar on the top of your screen and choose “Log out . . . .”
22b. For Linux Workstation: Click on “Actions” which is located at
the menue bar on the top of your screen and choose “Log out.”

You might also like