Presentation is loading. Please wait.

Presentation is loading. Please wait.

Linux Commands Workout 1

Similar presentations


Presentation on theme: "Linux Commands Workout 1"— Presentation transcript:

1 Linux Commands Workout 1
Fall 2017

2 Linux Filesystem Linux filename scheme
Hidden filenames start with a “.” (dot) most hidden files/directories are configuration-related (e.g., /home/john/.bashrc and /home/john/.ssh) Directory and filenames are case sensitive ls and LS are not the same foo.mp3 ≠ foo.MP3 filenames can include only alphanumerics plus dots, dashes, and underscores. however, most Linux filesystems allow the use of many non-alphanumeric characters, such as spaces, ~, ?, *, etc. the forward slash (/) is never allowed in filenames, as there could then be ambiguity in interpreting pathnames The tilde (~) sign is a shorthand notation for your home directory cd and cd ~ are equivalent ~ can be used as in relative pathnames when specifying a file/directory cd ~/test2

3 Linux Filesystem Example filenames: test1.text
Test1.text (completely different file from test1.text) test1.text.save3 ls (command/executable) .bashrc (hidden file) .ssh (hidden directory) a_long_name alternative-long-name file with space.text name (a name with spaces . even in extension)

4 Useful Linux Filesystem Commands
Explanation pwd Show/display current directory mkdir dir Make directory dir in CWD mkdir dir/subdir Make directory dir/subdir in CWD mkdir –p dir2/subdir Make directory dir2 and subdirectory ./dir2/subdir within dir2 cd dir Change from CWD to subdirectory dir cd .. Go up a directory cd ../dir2 Go up one level from CWD and then down to directory called dir2 ls List files in CWD touch file1.txt Create file1.txt in CWD touch ../dir2/file1.txt Create file1.txt in subdirectory dir2 of parent directory cp file1.txt ../dir2/file2 Copy file1.txt to file2 in location ../dir2 mv ./dir1/file1.txt ../dir2/file1.txt Move file1.txt in subdirectory ./dir1 to file2 in location ../dir2 (file1.txt will no longer be in ./dir1) mv file1.txt file2.txt Move file1.txt to file2.txt in the same directory. NOTE: This has the effect of renaming a file rm file1.txt Delete file1.txt from CWD rm –r dir2 Delete all files in subdirectory dir2 as well as dir2 ls argument options -a Show all (including hidden) -R Recursive list -r Reverse order -t Sort by last modified -S Sort by file size -l Long listing format -1 One file per line -m Comma-­sep­arated output -Q Quoted output

5 Basic Linux Commands to Teach

6

7

8 Linux commands workout
Create a file and change permissions on it using chown Change permissions on a directory Change permissions on a directory and all its contents recursively chown -R Get information on the processes currently running ps ps –e ps –ex Find out your IP address: ifconfig Test if your Internet is working: ping Introduce vi as the command line editor Show how to write data (in ‘i’ mode) Save as a file (:w) Exit vi (:q) Save and exit (:wq) Exit without saving (:w!)

9 Linux commands workout
Sort contents of a text file using the sort command more big-text_file.txt Display the file called big-text_file.txt one page at a time, proceed to next page using the spacebar head big-text_file.txt Display the first 10 lines of the file called big-text_file.txt head -20 big-text_file.txt Display the first 20 lines of the file called big-text_file.txt tail big-text_file.txt Display the last 10 lines of the file called big-text_file.txt tail -20 big-text_file.txt Display the last 20 lines of the file called big-text_file.txt


Download ppt "Linux Commands Workout 1"

Similar presentations


Ads by Google