![]() |
![]() |
||||
|
Basic LINUX Commands
Here are some basic commands that you need to work on the cluster. In these examples the commands themselves are highlighted in yellow and are followed by the output they produce.
Simple file listing: [abc123@seldon abc123]$ ls figure1.fig test.m test.sh Display extra details (file size, type, date, permissions) with the "long" (-l) option: [abc123@seldon abc123]$ ls -l total 12 -rw------- 1 abc123 users 1121 Oct 30 16:15 figure1.fig -rw------- 1 abc123 users 69 Oct 30 16:15 test.m -rwx------ 1 abc123 users 40 Oct 30 16:10 test.sh You can use wildcards to select only some of the files. [abc123@seldon abc123]$ ls -l test* -rw------- 1 abc123 users 69 Oct 30 16:15 test.m -rwx------ 1 abc123 users 40 Oct 30 16:10 test.sh
Print working directory path:
[abc123@seldon abc123]$ pwd
/sscc/home/a/abc123
Create a new subdirectory called [abc123@seldon abc123]$ mkdir subdir [abc123@seldon abc123]$ ls -l total 16 -rw------- 1 abc123 users 1121 Oct 30 16:15 figure1.fig drwx------ 2 abc123 users 4096 Nov 4 13:55 subdir -rw------- 1 abc123 users 69 Oct 30 16:15 test.m -rwx------ 1 abc123 users 40 Oct 30 16:10 test.sh
Switch to a subdirectory called
[abc123@seldon abc123]$ cd subdir
[abc123@seldon subdir]$
Two dots
[abc123@seldon subdir]$ cd ..
[abc123@seldon abc123]$
To use the full path start with a slash:
[abc123@seldon abc123]$ cd /datalib/cps
[abc123@seldon cps]$ pwd
/datalib/cps
Syntax: cp [options]... Source Destination cp [options]... Source... Directory Options:
Make a copy of a file called
[abc123@seldon abc123]$ cp -v make.do make2.do
`make.do' -> `make2.do'
Copy one or more files to another directory:
[abc123@seldon abc123]$ cp -v *.do subdir/
`make.do' -> `subdir/make.do'
`make2.do' -> `subdir/make2.do'
Copy the contents of a directory and its subdirectories to another place:
[abc123@seldon abc123]$ cp -vR subdir/* subdir2/
`subdir/make.do' -> `subdir2/make.do'
`subdir/make2.do' -> `subdir2/make2.do'
`subdir/data/file.dat' -> `subdir2/data/file.dat'
Remove a file called [abc123@seldon abc123]$ rm make.do
To remove a file with spaces in its name, use quotes: [abc123@seldon abc123]$ rm "file name.txt"
To remove multiple files (or to save time typing long file names)
use wildcards. Be careful - wildcards are
powerful and could match more files than you intended. Use the [abc123@seldon abc123]$ rm *.txt
Delete a subdirectory called [abc123@seldon abc123]$ rm -rf subdir
Display a more detailed manual for a command:
[ate533@seldon ate533]$ man cp CP(1) FSF CP(1) NAME cp - copy files and directories SYNOPSIS cp [OPTION]... SOURCE DEST cp [OPTION]... SOURCE... DIRECTORY cp [OPTION]... --target-directory=DIRECTORY SOURCE... DESCRIPTION Copy SOURCE to DEST, or multiple SOURCE(s) to DIRECTORY. . . .
You can use these powerful wildcards with any command that takes filenames as an argument. For example
You can reference your home directory in your commands and programs
with the character tilde /sscc/home/a/abc123then instead of writing out the full path to the file /sscc/home/a/abc123/data/input.datyou can just write ~/data/input.dat |
|||||||||||||||||||||||||||||||||||||||||
![]() |
Services |
Get Connected |
Support |
Educational Resources |
NUIT
|
|