Shell Tutorial For R User

Let’s go over some basic shell commends.

Get started

Command Description In R
whoami Who is the user? Sys.info() / whoami::whoami()
date Get date & time Sys.date() / Sys.time()
cal Display Calendar
clear Clear the screen Ctrl + L
whoami # who is the user

date # get data & time

cal # display canlendar

clear # clear the screen, crtl + l

Help/Documentation

Command Description In R
whatis Single line description of a command ? / ?? / help()
man Display manual pages for a command ? / ?? / help()
help Display manual pages for a command ? / ?? / help()
/? Display manual pages for a command ? / ?? / help()
man ls # help & documentation

whatis ls # single line description of a command

# help命令是bash内建命令,用于显示bash内建命令的帮助信息
Command Description In R
pwd Print working directory getwd() / here::here()
ls List directory contents dir() / list.files() / list.dirs() / dir_info() / fs::dir_ls()
cd Change current working directory setwd()
mkdir Create directory dir.create() / fs::dir_create()
rmdir Remove/delete directory fs::dir_delete()
pwd # pring working directory

ls # list files & folders

mkdir test # create directory called test

change working directory

Command Description
cd Navigate into directory
cd .. Go up one level
cd - Go to previous working directory
cd ~ Change directory to home directory
cd / Change directory to root directory
cd test # navigate into test directory

cd .. # go up to one level

cd - # go to previous working directory
  
cd ~ # change directory to home directory

cd / # change directory to root directory
  
rmdir test # remove empty directory, note that the folder must be empty

list the file and folders

Command Description
ls List directory contents
ls -l List files one per line
ls -a List all files, including hidden files
ls - la Display permission, ownership, size & modification date
ls -lh Long format with size displayed in human readable units
ls -lS Long format list sorted by size
ls -ltr Long format list sorted by modification date
Chen Xing
Chen Xing
Founder & Data Scientist

Enjoy Life & Enjoy Work!

Related