# Appropriate alternative to model selection for a multiple regression model

I've read up on the dangers of model selection and came across a neat example on this site for multiple regression whereby forward and backward stepwise selection can result in different final models:

library(MASS)
set.seed(1)

N <- 200000
y <- rnorm(N)
x1 <- y + rnorm(N)
x2 <- y + rnorm(N)
x3 <- y + rnorm(N)
x4 <- rnorm(N)
x5 <- rnorm(N)
x6 <- x1 + x2 + x3 + rnorm(N)
data <- data.frame(y, x1, x2, x3, x4, x5, x6)

fit1 <- lm(y ~ ., data)
fit2 <- lm(y ~ 1, data)
step(fit1,direction="backward")
step(fit2,direction="forward",scope=list(upper=fit1,lower=fit2))


I've since read that ridge regression or lasso regression are alternatives to this form of model selection. But in a simple case like this how would you go about constructing an appropriate model using something like these latter two approaches?