Back to Blog
Stony brook print queue7/23/2023 ![]() These are little bits of data that all programs can access, but which go away any time you log out. In addition to these commands, the shell has a few helpful features, one of which is the existence of environment variables. The shell is the program you're interacting with whenever you type something into the terminal, and is always running. ![]() The following syntax is used to specify flags:Īll of the commands described above are not programs, but functionality built into the shell. For example, -i flag makes grep case insensitive, -v flag prints out lines that do not match the specified pattern, -c flag prints out the number of the lines that contain the pattern, and -n flag prints out the matched lines and their line numbers. You can also add certain flags to the grep command, that will act as filters for search. For example, you can also print out a list of executed commands with a specific pattern by combining history with grep. Grep can be combined with other commands. The grep (globally search for regular expression and print out) command searches a file and displays all lines that contain a specified pattern (pattern can be just one word, or a whole sentence): The list is numbered, and you can execute a certain command from the history using ! command followed by the number of the command you want to run: You can see the full list of the commands you have executed with the history command: If you forget how to use a command, simply type that command followed by -h to get a description of it. Most of these commands have a help or -h option. A word of warning-it is very easy to accidentally delete important information. The recursive option is called such because it recursively deletes everything it finds. This will remove everything in that directory, files and subdirectories included. ![]() However, if you want to remove an entire directory (even if it's empty), you will have to pass it the -r option (short for recursive): For a regular file, you can choose not to pass it any options at all: You will pass this command different options, depending on what it is you want to remove. This command will permanently delete anything you tell it to (no trash bin!). If you want to delete a file or folder, you can use the rm command (short for remove). To display the content of a document you can use the cat command: You can then edit this file with a text editor of your choice (e.g., nano, vim, or emacs). If instead of a folder you would rather create a blank text file, you can use the touch command: For example, if you are in /gpfs/home/ and want to move to a subdirectory in that folder, just give cd the subdirectory name. A relative path does not start with a forward-slash, and fills in each subdirectory level up to the directory you're currently in. An absolute path begins with a forward-slash and specifies each level of subdirectories, starting from the root folder (which contains gpfs). You can change your directory using either an absolute or relative path. To change your present working directory, you can use the cd command, which stands for change directory. The home subdirectory of /gpfs contains all users' home directories. The top-level directory, equivalent to C: on Windows, is always /gpfs. When you type the pwd command, your working directory will be printed out to you: Your working directory is the command line equivalent of your current folder in Windows Explorer or Finder-it's the directory that you're currently looking at. Typing in ls will result in a list of files and subdirectories being printed back to you, all of which are located in your present working directory. ls and pwdĪfter you have done this, you can use the ls command to verify that the directory has been created without issue. ![]() Here, is the name you want to give the folder. You can make subdirectories, files, and even install software here. This is your own private folder to store things related to your work. When you first log in you will arrive in your home directory. Here, the use of the terminal is mandatory, so it is important that you know your way around it. Windows and OS X both have their own version of the terminal, even though most users choose not to use them. Unlike a desktop, you interact with this operating system through the terminal, sometimes referred to as the command line. SeaWulf uses CentOS as its operating system, one of the many variants of Linux. It serves to get you acquainted with the environment you will be interacting with once on the system. This guide assumes you have already received access to SeaWulf, and that you are able to log in.
0 Comments
Read More
Leave a Reply. |